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

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

  actionConfig={{
    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.

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

NftFillAskConfig

actionConfig={{
  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

Payment

interface TokenPayment {
  amount: bigint;
  isNative?: false;
  tokenAddress: Address;
}
 
interface NativePayment {
  amount: bigint;
  isNative: true;
  tokenAddress?: Address;
}
 
export type Payment = TokenPayment | NativePayment;
ParameterDescriptionDefault
amountWEI required to complete txN/A
isNativeDictate if transaction in ERC20 or gas tokenRequired - set to true if native
tokenAddressERC20 token address for txRequired if !isNative

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.

interface BoxActionResponse {
  tx: Transaction;
  tokenPayment?: Payment;
  applicationFee?: Payment;
  bridgeFee?: Payment;
  bridgeId?: BridgeId;
};
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
bridgeFeeFee that the bridge provider collects
bridgeIdID of the bridge used for this transaction.

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;
}