Skip to content

Types

Glossary of types exported from Box Common. These types are used across @decent.xyz/the-box, @decent.xyz/box-hooks, and @decent.xyz/box-ui packages.

Address

type SolanaAddress = string;
type CosmosAddress = string;
type EvmAddress = `0x${string}`;
type Address = EvmAddress | SolanaAddress | CosmosAddress;

ActionType

Action types help define parameters for common transaction types. The ActionType is a required argument to send any Decent transaction. Each ActionType has a corresponding ActionConfig.

ActionTypeDescriptionActionConfig
ActionType.EvmFunctionBuild the calldata for any EVM transaction. Default option.EvmFunction
ActionType.SwapActionExecute a cross-chain swap.SwapActionConfig
ActionType.NftMintMint an NFT.NftMintConfig
ActionType.NftPreferMintMint. If sold out, buy on secondary if there are available listings.NftPreferMintConfig
ActionType.NftFillAskBuy an NFT off secondaries.NftFillAsk
ActionType.EvmCalldataTxPass in the calldata required to execute the transaction. See exampleEvmCalldataTx

ActionConfig

Action types above extend BaseActionConfig to fulfill the desired transaction. ActionConfig is required to send any transaction.

BaseActionConfig

interface BaseActionConfig {
  chainId: ChainId;
  cost?: Payment;
  allowSwapping?: boolean;
  allowBridging?: boolean;
  onlyAllowTokens?: Lookup<ChainId, Address[]>;
  contractAddress?: Address;
}
ParameterDescriptionDefault
chainIdChain ID of the destination network.N/A
costToken and value required to complete the transaction.N/A
allowSwappingOptionally prevent any-token payments.true
allowBridgingOptionally prevent cross-chain transactions.true
onlyAllowTokensSpecify a target list of accepted tokens (e.g., only ETH & USDC).Any token with DeFi liquidity.
contractAddressTarget contract address to call in transaction.N/A

EvmFunction

{{
  chainId: ChainId,
  contractAddress: Address,
  cost: Payment,
  signature: string,
  args: Array,
}}
ParameterDescriptionDefault
signatureSmart contract function signature for target action.N/A
argsArguments required to fulfill signature.N/A

SwapActionConfig

enum SwapDirection {
  EXACT_AMOUNT_IN = 'exact-amount-in',
  EXACT_AMOUNT_OUT = 'exact-amount-out',
}
 
interface SwapActionConfig extends BaseActionConfig {
swapDirection: SwapDirection;
amount: bigint;
receiverAddress?: Address;
}
ParameterDescriptionDefault
swapDirectionDirection of swap calculation.N/A
amountWEI requested to swap.N/A
receiverAddressTarget address to receive funds on destination chain.Sender's wallet address.

NftMintConfig

The NftMintConfig and EvmFunction configs are equivalent. Different action types exist strictly to help guide developer effort.

{{
  chainId: ChainId,
  contractAddress: Address,
  cost: Payment,
  signature: string,
  args: Array,
}}

NftFillAskConfig

{{
  chainId: ChainId,
  contractAddress: Address,
  tokenId: number,
}}
ParameterDescriptionDefault
tokenIdID of NFT in collection to purchase.ID of lowest priced NFT in collection.
recipientOptionally send purchased NFT to another wallet.Sender's wallet address.

NftPreferMintConfig

These additional parameters are to signal the end of an NFT's mint. Once the mint ends, Decent will automatically source the lowest priced available listing on secondary markets, so that users can continue to purchase NFTs from the same interface.

actionConfig={{
  chainId: ChainId,
  contractAddress: Address,
  cost: Payment,
  signature: string,
  args: Array,
  supplyConfig: {
    maxCap?: number,
    sellOutDate?: number,
  }
}}
ParameterDescriptionDefault
maxCapTotal number of NFTs in collection.undefined
sellOutDateUnix timestamp for NFT mint's end time.undefined

BoxActionRequest

Schema for arguments passed to the useBoxAction hook or /getBoxAction API endpoint.

interface BoxActionRequest {
  sender: string;
 
  srcToken: string;
  srcChainId: ChainId;
  dstToken: string;
  dstChainId: ChainId;
  slippage: number;
 
  actionType: ActionType;
  actionConfig: ActionConfig;
  enable?: boolean;
}
ParameterDescription
srcToken & dstTokenERC-20 token addresses. Use the zero address if it's a native token. Viem exports this.
srcChainId & dstChainIdThe chain ID's of the source and the destination chains. If your transaction is not crosschain, set them to the same ID.
slippageAmount of slippage you'd allow in your route. Cannot be zero, the default value is 1.
actionType & actionConfigAny of our supported action types and their corresponding action configs.
enable (optional)Set to false to disable the query for automatically running - similar to wagmi's enabled option.

BoxActionResponse

Schema of the response from either the useBoxAction hook or /getBoxAction API endpoint.

Sample response

{
    "tx": {
        "to": "0x1572D48a52906B834FB236AA77831d669F6d87A1",
        "chainId": 10,
        "data": "0x49406927000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000005c00000000000000000000000000000000000000000000000000000000000000660000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002105000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000005d7370fcd6e446bbc14a64c1effe5fbb1c89323200000000000000000000000000000000000000000000000000000000000004a0000000000000000000000000000000000000000000000000000000000000052000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000600000000000000000000000001572d48a52906b834fb236aa77831d669f6d87a10000000000000000000000005d7370fcd6e446bbc14a64c1effe5fbb1c893232000000000000000000000000000000000000000000000000016345785d8a0000000000000000000000000000000000000000000000000000016345785d8a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000006000000000000000000000000043019f8be1f192587883b67dea2994999f5a2de20000000000000000000000005d7370fcd6e446bbc14a64c1effe5fbb1c893232000000000000000000000000000000000000000000000000016345785d8a0000000000000000000000000000000000000000000000000000000000000e7f7e4b0000000000000000000000004200000000000000000000000000000000000006000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000002b4200000000000000000000000000000000000006000064833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044a9059cbb0000000000000000000000005d7370fcd6e446bbc14a64c1effe5fbb1c893232000000000000000000000000000000000000000000000000000000000e7f7e4b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000001e8480b38801d6000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000035397ac36e0900000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004178cc11482be0f2c3e4b22d97144d3c0bfad88a13950f15d57a55a9497509dde731824c4ce494e21f20e76269020b19275ccae3821a10cfc83149d668056352ff1b00000000000000000000000000000000000000000000000000000000000000",
        "value": "100268520989036041n"
    },
    "tokenPayment": {
        "amount": "100000000000000000n",
        "tokenAddress": "0x0000000000000000000000000000000000000000",
        "chainId": 10,
        "isNative": true,
        "name": "Ether",
        "symbol": "ETH",
        "decimals": 18
    },
    "amountOut": {
        "amount": "243236427n",
        "tokenAddress": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
        "chainId": 8453,
        "isNative": false,
        "name": "USD Coin",
        "symbol": "USDC",
        "decimals": 6
    },
    "protocolFee": {
        "amount": "210000000000000n",
        "tokenAddress": "0x0000000000000000000000000000000000000000",
        "chainId": 10,
        "isNative": true,
        "name": "Ether",
        "symbol": "ETH",
        "decimals": 18
    },
    "applicationFee": {
        "amount": "0n",
        "tokenAddress": "0x0000000000000000000000000000000000000000",
        "chainId": 10,
        "isNative": true,
        "name": "Ether",
        "symbol": "ETH",
        "decimals": 18
    },
    "bridgeFee": {
        "amount": "58520989036041n",
        "tokenAddress": "0x0000000000000000000000000000000000000000",
        "chainId": 10,
        "isNative": true,
        "name": "Ether",
        "symbol": "ETH",
        "decimals": 18
    },
    "bridgeIds": [
        "decent"
    ],
    "exchangeRate": 2432.36427,
    "estimatedTxTime": 23
}
interface BoxActionResponse {
  tx: {
    to: Address; // `0x${string}`
    chainId: ChainId;
    data: Hash; // `0x${string}`
    value: string; // bigint - e.g., "10000000n"
  };
  tokenPayment: Payment;
  amountOut: Payment;
  applicationFee: Payment;
  exchangeRate: number;
  bridgeId?: BridgeId;
  estimatedTxTime: number;
}
ParameterDescription
txA Transaction object you can use to submit with your dapp
tokenPaymentSource payment token for the action taken.
applicationFeeFee that the implementing application collects
bridgeIdID of the bridge used for this transaction.
exchangeRateExchange rate between the source, tokenPayment.tokenAddress, and destination, amountOut.tokenAddress, tokens.
estimatedTxTimeEstimated time until the destination tx confirms.

ChainId

ChainId is an enum that provides quick access to the Chain ID's of Decent's supported chains.

enum ChainId {
  ETHEREUM = 1,
  SEPOLIA = 11155111,
  OPTIMISM = 10,
  OPTIMISM_SEPOLIA = 11155420,
  POLYGON = 137,
  POLYGON_TESTNET = 80001,
  ARBITRUM = 42161,
  ARBITRUM_SEPOLIA = 421614,
  BASE = 8453,
  SOLANA_MAINNET = 1399811149,
  ...
}

TokenInfo

interface TokenId {
  address: Address;
  chainId: ChainId;
}
 
interface TokenInfo extends TokenId {
  decimals: number;
  symbol: string;
  name: string;
  isNative: boolean;
  chainId: ChainId;
  logo?: string;
}