### Install Tokenbound SDK Source: https://github.com/tokenbound/sdk/blob/main/packages/sdk/README.md Install the SDK using npm. This is the first step before using the library. ```bash $ npm install @tokenbound/sdk ``` -------------------------------- ### Install and Build Tokenbound SDK Packages Source: https://github.com/tokenbound/sdk/blob/main/README.md Clone the repository, install dependencies, and build the SDK packages. Local changes to SDK methods require a rebuild. ```bash # clone the repo $ git clone # install dependencies $ pnpm install # build packages $ pnpm --filter "@tokenbound/*" build ``` -------------------------------- ### Build SDK Source: https://github.com/tokenbound/sdk/blob/main/README.md Build the Tokenbound SDK by cleaning previous builds, installing dependencies, and compiling the project. This step is necessary before generating ABIs or running tests. ```bash pnpm clean && pnpm i && pnpm build ``` -------------------------------- ### Run All Tests Source: https://github.com/tokenbound/sdk/blob/main/README.md Execute all unit tests by spinning up an Anvil instance and starting Vitest. This command assumes the SDK has been built and ABIs have been generated. ```bash pnpm test ``` -------------------------------- ### Ethers 5 ArrayLike Message Example Source: https://github.com/tokenbound/sdk/blob/main/README.md Example of preparing a message as an ArrayLike for signing with Ethers 5. ```typescript // Ethers 5 const arrayMessage: ArrayLike = [72, 101, 108, 108, 111] // "Hello" in ASCII ``` -------------------------------- ### Ethers 5 or Ethers 6 Uint8Array Message Example Source: https://github.com/tokenbound/sdk/blob/main/README.md Example of preparing a message as a Uint8Array for signing with Ethers 5 or Ethers 6. ```typescript // Ethers 5 or Ethers 6 const uint8ArrayMessage: Uint8Array = new Uint8Array([72, 101, 108, 108, 111]) // "Hello" in ASCII ``` -------------------------------- ### Instantiate TokenboundClient with Custom Implementation and Registry Source: https://github.com/tokenbound/sdk/blob/main/packages/sdk/README.md Instantiate the TokenboundClient with both a custom implementation address and a custom registry address. This is uncommon and typically only needed for highly customized setups. ```javascript import { TokenboundClient } from "@tokenbound/sdk"; const tokenboundClientWithCustomRegistry = new TokenboundClient({ signer: , chainId: , implementationAddress: "", registryAddress: "", }) ``` -------------------------------- ### getAccount Source: https://github.com/tokenbound/sdk/blob/main/README.md Gets the tokenbound account address for an NFT. Returns the tokenbound account address for a given token contract and token ID. ```APIDOC ## getAccount ### Description Gets the tokenbound account address for an NFT. ### Method `getAccount(args: { tokenContract: string tokenId: string salt?: number }): string ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **tokenContract** (string) - Required - The address of the token contract. * **tokenId** (string) - Required - The token ID. * **salt** (number) - Optional - The salt used when the account was created. ### Request Example ```typescript const tokenboundAccount = tokenboundClient.getAccount({ tokenContract: '', tokenId: '', }) console.log(tokenboundAccount) ``` ### Response #### Success Response Returns the tokenbound account address for a given token contract and token ID. #### Response Example ```json "0x1a2...3b4cd" ``` ``` -------------------------------- ### Append Calls to Tokenbound Account Creation Source: https://github.com/tokenbound/sdk/blob/main/README.md Chain transactions to execute immediately after a new Tokenbound Account (TBA) is created and initialized. This example claims an ERC-1155 token. ```typescript import { Call3 } from '@tokenbound/sdk' import { encodeFunctionData } from 'viem' const tokenboundAccount = tokenboundClient.getAccount({ tokenContract: "", tokenId: "", }) // Let's claim an ERC-1155 token from one of ThirdWeb's DropERC1115 contract deployments // https://thirdweb.com/thirdweb.eth/DropERC1155 const maxClaimablePerWallet = 1 const pricePerToken = 0 const quantity = 1 const currencyAddress = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE' // ETH // Configure the arguments for the claim const claimConfig = { receivingTBA: tokenboundAccount, pricePerToken, quantity, tokenId: 0, currencyAddress, allowListProof: { proof: [], quantityLimitPerWallet: maxClaimablePerWallet ?? 1, pricePerToken, currency: currencyAddress, }, data: '0x', } // Encode function data for use in prepareExecution call const encodedClaimFunctionData = encodeFunctionData({ abi: rewardContractABI, functionName: 'claim', args: [ claimConfig.receivingTBA, claimConfig.tokenId, claimConfig.quantity, claimConfig.currencyAddress, claimConfig.pricePerToken, claimConfig.allowListProof, claimConfig.data, ], }) // Prepare execution call via Tokenbound account const preparedExecution = await tokenboundClient.prepareExecution({ account: tokenboundAccount, to: CLAIM_CONTRACT_ADDRESS, value: 0n, data: encodedClaimFunctionData, }) // Assemble a Call3 call that can be used by createAccount's internal Multicall3 invocation const appendedCall: Call3 = { target: tokenboundAccount, // <-- Execute with TBA contract allowFailure: false, callData: preparedExecution.data, // <-- Encoded TBA 'execute' function data } const { account, txHash } = await tokenboundClient.createAccount({ tokenContract: "", tokenId: "", appendedCalls: [appendedCall] // <-- Call(s) to be executed sequentially after account creation }) console.log(account) //0x1a2...3b4cd ``` -------------------------------- ### Get Tokenbound Account Address Source: https://github.com/tokenbound/sdk/blob/main/README.md Retrieves the deterministic address of a Tokenbound account for a given NFT. This address can receive assets even before the account is deployed. ```typescript const tokenboundAccount = tokenboundClient.getAccount({ tokenContract: '', tokenId: '', }) console.log(tokenboundAccount) //0x1a2...3b4cd ``` -------------------------------- ### Get ERC-6551 Account Address Source: https://github.com/tokenbound/sdk/blob/main/packages/sdk/README.md Retrieve the ERC-6551 account address for a given token. Requires the token contract address and token ID. ```javascript import { TokenboundClient } from "@tokenbound/sdk"; import { goerli } from 'viem/chains'; const tokenboundClient = new TokenboundClient({ walletClient, chainId: goerli.id }); const tokenBoundAccount = tokenboundClient.getAccount({ tokenContract: "", tokenId: "", }); ``` -------------------------------- ### signMessage Source: https://github.com/tokenbound/sdk/blob/main/README.md Gets an EIP-191 formatted signature for a message. The message can be a string, Uint8Array, or a raw Uint8Array object for viem compatibility. Returns a Promise that resolves to a signed Hex string. ```APIDOC ## signMessage ### Description Gets an [EIP-191](https://eips.ethereum.org/EIPS/eip-191) formatted signature for a message. The message to be signed is typed as `UniversalSignableMessage` so that it can elegantly handle Ethers 5, Ethers 6, and viem's expected types for all signable formats. **Returns** a Promise that resolves to a signed Hex string. ### Method `signMessage` ### Parameters #### Request Body - **message** (UniversalSignableMessage) - Required - The message to be signed. ### Request Example ```ts // Example using a string message const signedMessage = await tokenboundClient.signMessage({ message: 'Ice cream so good', }) console.log(signedMessage) // Example using Uint8Array (works in Ethers 5 or Ethers 6) const uint8ArrayMessage: Uint8Array = new Uint8Array([72, 101, 108, 108, 111]) // "Hello" in ASCII const signedUint8Message = await tokenboundClient.signMessage({ message: uint8ArrayMessage, }) console.log(signedUint8Message) // Example using raw Uint8Array object (works in viem) const signedRawUint8Message = await tokenboundClient.signMessage({ message: { raw: uint8ArrayMessage }, }) console.log(signedRawUint8Message) ``` ### Response #### Success Response - **signedHex** (string) - A Hex string representing the EIP-191 signature. #### Response Example ```json { "signedHex": "0x..." } ``` ``` -------------------------------- ### Get Tokenbound Account Address Source: https://github.com/tokenbound/sdk/blob/main/README.md Call the getAccount method on the TokenboundClient to retrieve the address of a tokenbound account. Requires the token contract address and token ID. ```typescript const tokenboundClient = new TokenboundClient({ walletClient, chainId: 1 }) const tokenboundAccount = tokenboundClient.getAccount({ tokenContract: '', tokenId: '', }) console.log(tokenboundAccount) //0x1a2...3b4cd ``` -------------------------------- ### Get NFT Associated with Tokenbound Account Source: https://github.com/tokenbound/sdk/blob/main/README.md Retrieves information about the NFT linked to a tokenbound account. The returned object includes the token contract address, token ID, and chain ID. ```typescript const nft = await tokenboundClient.getNFT({ accountAddress: '', }) const { tokenContract, tokenId, chainId } = nft console.log({ tokenContract, tokenId, chainId }) ``` -------------------------------- ### Instantiate TokenboundClient with Viem WalletClient Source: https://github.com/tokenbound/sdk/blob/main/packages/sdk/README.md Instantiate the TokenboundClient using viem's WalletClient. Ensure you have the correct chain ID. ```javascript import { TokenboundClient } from "@tokenbound/sdk"; import { goerli } from 'viem/chains' const tokenboundClient = new TokenboundClient({ walletClient, chainId: goerli.id }); ``` -------------------------------- ### Initialize TokenboundClient with Custom Implementation and Registry Source: https://github.com/tokenbound/sdk/blob/main/README.md This is an uncommon configuration for custom deployments that also require a custom registry address. ```javascript // Custom implementation AND custom registry (uncommon for most implementations) const tokenboundClientWithCustomRegistry = new TokenboundClient({ walletClient: '', chainId: '', implementationAddress: '', registryAddress: '', }) ``` -------------------------------- ### TokenboundClient Instantiation with WalletClient Source: https://github.com/tokenbound/sdk/blob/main/README.md Instantiate the TokenboundClient using a viem walletClient and a chainId for standard configurations. ```APIDOC ## TokenboundClient Instantiation with WalletClient ### Description Instantiate the TokenboundClient using a viem `walletClient` and a `chainId` for standard configurations. ### Parameters - `walletClient` (WalletClient) - Mandatory: The viem wallet client. - `chainId` (number) - Mandatory: The chain ID. ### Code Example ```typescript import { createWalletClient, http, publicActions, walletActions } from 'viem' import { goerli } from 'viem/chains' import { TokenboundClient } from '@tokenbound/sdk' const walletClient = createWalletClient({ account: '', chain: goerli, transport: http(), }) const tokenboundClient = new TokenboundClient({ walletClient, chainId: goerli.id }) ``` ``` -------------------------------- ### Initialize TokenboundClient with Custom Implementation Source: https://github.com/tokenbound/sdk/blob/main/README.md Use this when your deployed account implementation contract differs from the default. Provide the custom implementation address. ```javascript import { TokenboundClient } from '@tokenbound/sdk' const tokenboundClient = new TokenboundClient({ walletClient: '', chainId: '', implementationAddress: '', }) ``` -------------------------------- ### TokenboundClient Instantiation with Custom Chain Source: https://github.com/tokenbound/sdk/blob/main/README.md Instantiate the TokenboundClient using a viem walletClient and a custom viem Chain object when the chain is not standard. ```APIDOC ## TokenboundClient Instantiation with Custom Chain ### Description Instantiate the TokenboundClient using a viem `walletClient` and a custom viem `Chain` object when your chain isn't listed in standard configurations. ### Parameters - `walletClient` (WalletClient) - Mandatory: The viem wallet client. - `chain` (Chain) - Mandatory: The custom viem Chain object. ### Code Example ```typescript import { createWalletClient, http } from 'viem' import { zora } from 'viem/chains' import { TokenboundClient } from '@tokenbound/sdk' const walletClient = createWalletClient({ account: '', chain: zora, transport: http(), }) const tokenboundClient = new TokenboundClient({ walletClient, chain: zora }) ``` ``` -------------------------------- ### Instantiate TokenboundClient with Custom Chain Source: https://github.com/tokenbound/sdk/blob/main/README.md Configure the client with a custom chain object from viem/chains when your chain is not listed on the deployments page. Requires a walletClient. ```typescript import { zora } from 'viem/chains' const tokenboundClient = new TokenboundClient({ walletClient, chain: zora }) ``` -------------------------------- ### Instantiate TokenboundClient with Standard Chain Source: https://github.com/tokenbound/sdk/blob/main/README.md Use this configuration when using standard V2/V3 ERC-6551 contract deployments and a chain supported by viem. Requires wagmi's useAccount and createWalletClient. ```typescript import { useAccount, WalletClient } from 'wagmi' import { TokenboundClient } from '@tokenbound/sdk' const { address } = useAccount() const walletClient: WalletClient = createWalletClient({ chainId: goerli, account: address, transport: http(), }) const tokenboundClient = new TokenboundClient({ walletClient, chainId: 5 }) ``` -------------------------------- ### Initialize TokenboundClient for Legacy V2 Account Source: https://github.com/tokenbound/sdk/blob/main/README.md Specify `TBVersion.V2` when using the standard legacy V2 account implementation to ensure compatibility. ```typescript import { TokenboundClient, TBVersion } from '@tokenbound/sdk' const tokenboundClient = new TokenboundClient({ walletClient, chainId: 1, version: TBVersion.V2, }) ``` -------------------------------- ### Instantiate TokenboundClient with Legacy Signer Source: https://github.com/tokenbound/sdk/blob/main/packages/sdk/README.md Instantiate the TokenboundClient using a legacy Wagmi or Ethers signer. Provide the chain ID. ```javascript import { TokenboundClient } from "@tokenbound/sdk"; const tokenboundClient = new TokenboundClient({ signer, chainId: 1 }); ``` -------------------------------- ### prepareExecution Source: https://github.com/tokenbound/sdk/blob/main/README.md Prepares an arbitrary contract call for execution against any contract. Replaces the deprecated V2 method `prepareExecuteCall`. ```APIDOC ## prepareExecution ### Description Prepares an arbitrary contract call for execution against any contract. This method replaces the deprecated V2 method `prepareExecuteCall`. Returns a Promise with a prepared transaction to execute a call on a Tokenbound account. ### Method Not specified (SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **account** (string) - Required - The Tokenbound account address. - **to** (string) - Required - The contract address. - **value** (bigint) - Required - The value to send, in wei. - **data** (string) - Optional - The ABI-encoded call data. ### Request Example ```typescript const preparedExecution = await tokenboundClient.prepareExecution({ account: '', to: '', value: '', data: '', }) ``` ### Response #### Success Response - **Prepared Transaction** - A transaction object ready to be sent. ``` -------------------------------- ### prepareCreateAccount Source: https://github.com/tokenbound/sdk/blob/main/README.md Prepares an account creation transaction to be submitted via `sendTransaction`. Returns a promise resolving to a prepared transaction that can be used to create a Tokenbound account for a given token contract and token ID. ```APIDOC ## prepareCreateAccount ### Description Prepares an account creation transaction to be submitted via `sendTransaction`. ### Method `prepareCreateAccount(args: { tokenContract: string tokenId: string salt?: number chainId?: number appendedCalls?: Call3[] }): Promise ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **tokenContract** (string) - Required - The address of the token contract. * **tokenId** (string) - Required - The token ID. * **salt** (number) - Optional - The salt used to create a unique account address. * **chainId** (number) - Optional - The id of the chain on which the account will exist. * **appendedCalls** (Call3[]) - Optional - An array of calls to execute via Multicall3. ### Request Example ```typescript const preparedAccount = await tokenboundClient.prepareCreateAccount({ tokenContract: '', tokenId: '', }) console.log(preparedAccount) ``` ### Response #### Success Response Returns a promise resolving to a prepared transaction that can be used to create a Tokenbound account. The exact type depends on the implementation (V2, V3 standard, or V3 custom). #### Response Example ```json { "to": "0x...", "value": 0, "data": "0x..." } ``` ``` -------------------------------- ### Instantiate TokenboundClient with Ethers Signer Source: https://github.com/tokenbound/sdk/blob/main/README.md Use this configuration if you are integrating with Ethers.js v5/v6 instead of viem. Requires wagmi's useSigner. ```typescript const { data: signer } = useSigner() const tokenboundClient = new TokenboundClient({ signer, chainId: 1 }) ``` -------------------------------- ### Prepare Tokenbound Account Creation Transaction Source: https://github.com/tokenbound/sdk/blob/main/README.md Prepares a transaction to create a Tokenbound account. Use this when you need to submit the transaction via `sendTransaction`. ```typescript const preparedAccount = await tokenboundClient.prepareCreateAccount({ tokenContract: '', tokenId: '', }) console.log(preparedAccount) //0x1a2...3b4cd ``` -------------------------------- ### Create Tokenbound Account Source: https://github.com/tokenbound/sdk/blob/main/README.md Creates a Tokenbound account for an NFT, adding it to the registry and initializing it. The account address can receive assets before deployment. ```typescript const { account, txHash } = await tokenboundClient.createAccount({ tokenContract: '', tokenId: '', }) console.log(account) //0x1a2...3b4cd ``` -------------------------------- ### TokenboundClient Instantiation with Ethers Signer Source: https://github.com/tokenbound/sdk/blob/main/README.md Instantiate the TokenboundClient using an Ethers signer and a chainId, suitable for legacy projects. ```APIDOC ## TokenboundClient Instantiation with Ethers Signer ### Description Instantiate the TokenboundClient using an Ethers `signer` and a `chainId`. This is an alternative for legacy projects not using viem. ### Parameters - `signer` (Signer) - Mandatory: The Ethers signer instance. - `chainId` (number) - Mandatory: The chain ID. ### Code Example ```typescript import { ethers } from 'ethers' import { TokenboundClient } from '@tokenbound/sdk' const provider = new ethers.providers.Web3Provider(window.ethereum) const signer = provider.getSigner() const tokenboundClient = new TokenboundClient({ signer, chainId: 1 }) ``` ``` -------------------------------- ### createAccount Source: https://github.com/tokenbound/sdk/blob/main/README.md Creates a tokenbound account for an NFT. The deterministic address is calculated using the `create2` opcode. This method adds the account to the registry and initializes it for use. ```APIDOC ## createAccount ### Description Creates a tokenbound account for an NFT. The deterministic address is calculated using the `create2` opcode using the listed parameters along with chainId and implementation address. `createAccount` adds the account to the registry and initializes it for use. Prior to account creation, the address can already receive assets. Deploying the account allows the NFT's owner to interact with the account. ### Method `createAccount(args: { tokenContract: string tokenId: string salt?: number chainId?: number appendedCalls?: Call3[] }): Promise<{ account: string, txHash: string }> ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **tokenContract** (string) - Required - The address of the token contract. * **tokenId** (string) - Required - The token ID. * **salt** (number) - Optional - The salt used to create a unique account address. * **chainId** (number) - Optional - The id of the chain on which the account will exist. * **appendedCalls** (Call3[]) - Optional - An array of calls to execute via Multicall3. ### Request Example ```typescript const { account, txHash } = await tokenboundClient.createAccount({ tokenContract: '', tokenId: '', }) console.log(account) ``` ### Response #### Success Response Returns an object containing the account address of the tokenbound account created and the hash of the transaction. If an account already exists, the existing account is returned. #### Response Example ```json { "account": "0x1a2...3b4cd", "txHash": "0xabc...123" } ``` ``` -------------------------------- ### Configure TokenboundClient with Custom RPC URL Source: https://github.com/tokenbound/sdk/blob/main/README.md Instantiate TokenboundClient providing a custom RPC URL for its internal PublicClient. This is useful for local testing. ```javascript import { TokenboundClient } from '@tokenbound/sdk' const tokenboundClient = new TokenboundClient({ walletClient: '', chainId: '', publicClientRPCUrl: '', }) ``` -------------------------------- ### Instantiate TokenboundClient with Custom Implementation Source: https://github.com/tokenbound/sdk/blob/main/packages/sdk/README.md Instantiate the TokenboundClient with a custom ERC-6551 implementation address. This is useful if you are using a non-standard implementation. ```javascript import { TokenboundClient } from "@tokenbound/sdk"; const tokenboundClient = new TokenboundClient({ signer: , chainId: , implementationAddress: "", }) ``` -------------------------------- ### Sign a Raw Uint8Array Message (viem) Source: https://github.com/tokenbound/sdk/blob/main/README.md This snippet shows how to sign a message formatted as a raw Uint8Array, specifically for use with viem. Ensure your message is correctly structured for viem compatibility. ```typescript const uint8ArrayMessage: Uint8Array = new Uint8Array([72, 101, 108, 108, 111]) // "Hello" in ASCII // Works in viem const signedRawUint8Message = await tokenboundClient.signMessage({ message: { raw: uint8ArrayMessage }, }) console.log(signedUint8Message) ``` -------------------------------- ### Environment Variables for Testing Source: https://github.com/tokenbound/sdk/blob/main/README.md Configure necessary environment variables for Vite to pick up during testing. Ensure the VITE_ prefix is used for Vite compatibility. Replace placeholders with your actual API keys and endpoints. ```dotenv # VITE_ prefix is required for Vite to pick up the env vars # PRIVATE KEYS CAN GO HERE VITE_PRIVATE_ALCHEMY_API_KEY=REPLACE_WITH_YOUR_ALCHEMY_API_KEY # PUBLIC ENV VARS, add to `.env`: VITE_ANVIL_MAINNET_FORK_ENDPOINT=https://eth-mainnet.alchemyapi.io/v2/$VITE_PRIVATE_ALCHEMY_API_KEY VITE_ANVIL_MAINNET_FORK_BLOCK_NUMBER=21023556 ``` -------------------------------- ### Generate ABIs Source: https://github.com/tokenbound/sdk/blob/main/README.md Generate Application Binary Interfaces (ABIs) using the Wagmi CLI. This command is essential for contract interactions within the SDK's testing environment. ```bash pnpm wagmi ``` -------------------------------- ### Check Tokenbound Account Deployment Source: https://github.com/tokenbound/sdk/blob/main/README.md Verifies if a tokenbound account has been deployed. Use this to confirm if an account has been activated via `createAccount`. ```typescript const SAPIENZ_GOERLI_TOKEN_TBA_TOKENID_0 = '0x33D622b211C399912eC0feaaf1caFD01AFA53980' as `0x${string}` const isAccountDeployed = await tokenboundClient.checkAccountDeployment({ accountAddress: SAPIENZ_GOERLI_TOKEN_TBA_TOKENID_0, }) console.log('IS SAPIENZ 0 DEPLOYED?', isAccountDeployed) //... ``` -------------------------------- ### Encode and Execute Call to ERC-6551 Account Source: https://github.com/tokenbound/sdk/blob/main/packages/sdk/README.md Prepare and execute a call to an ERC-6551 account. This involves encoding the transaction details and then sending it via the wallet client. ```javascript import { prepareExecuteCall } from "@tokenbound/sdk"; const to = "0xe7134a029cd2fd55f678d6809e64d0b6a0caddcb"; // any address const value = 0n; // amount of ETH to send in WEI const data = ""; // calldata const preparedCall = await tokenboundClient.prepareExecuteCall({ account: "", to: "", value: value, data: data, }); // Execute encoded call const hash = await walletClient.sendTransaction(preparedCall); ``` -------------------------------- ### checkAccountDeployment Source: https://github.com/tokenbound/sdk/blob/main/README.md Checks if a Tokenbound account address has been activated. Returns a boolean indicating deployment status. ```APIDOC ## checkAccountDeployment ### Description Checks if a Tokenbound account address has been activated using `createAccount`. Returns a boolean indicating if a tokenbound account has been deployed (created) at the `accountAddress`. ### Method Not specified (SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **accountAddress** (string) - Required - The Tokenbound account address. ### Request Example ```ts const isAccountDeployed = await tokenboundClient.checkAccountDeployment({ accountAddress: '0x33D622b211C399912eC0feaaf1caFD01AFA53980', }) ``` ### Response #### Success Response - **boolean** - Indicates if the account has been deployed. ``` -------------------------------- ### Sign a Uint8Array Message (Ethers 5/6) Source: https://github.com/tokenbound/sdk/blob/main/README.md This snippet demonstrates signing a message provided as a Uint8Array, compatible with Ethers 5 and Ethers 6. Note that this format may throw an error in viem. ```typescript const uint8ArrayMessage: Uint8Array = new Uint8Array([72, 101, 108, 108, 111]) // "Hello" in ASCII // Works in Ethers 5 or 6, throws in viem const signedUint8Message = await tokenboundClient.signMessage({ message: uint8ArrayMessage, }) console.log(signedUint8Message) ``` -------------------------------- ### Prepare Arbitrary Contract Call Source: https://github.com/tokenbound/sdk/blob/main/README.md Prepares a transaction for executing an arbitrary contract call on a tokenbound account. This method replaces the deprecated `prepareExecuteCall`. ```typescript const preparedExecution = await tokenboundClient.prepareExecution({ account: '', to: '', value: '', data: '', }) console.log(preparedExecution) //... ``` -------------------------------- ### Sign a String Message Source: https://github.com/tokenbound/sdk/blob/main/README.md Use this snippet to sign a simple string message. The signature is returned as a Promise resolving to a Hex string. ```typescript const signedMessage = await tokenboundClient.signMessage({ message: 'Ice cream so good', }) console.log(signedMessage) ``` -------------------------------- ### execute Source: https://github.com/tokenbound/sdk/blob/main/README.md Performs an arbitrary contract call against any contract, enabling actions like minting or transferring NFTs. Replaces the deprecated V2 method `executeCall`. ```APIDOC ## execute ### Description Performs an arbitrary contract call against any contract. This means any onchain action you can perform with your EOA wallet can be done with your NFT's Tokenbound account. You can mint or transfer NFTs, approve contracts, make and vote on DAO proposals, and much more. This method replaces the deprecated V2 method `executeCall`. Returns a hash of the transaction that executed a call using a Tokenbound account. ### Method Not specified (SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **account** (string) - Required - The Tokenbound account address. - **to** (string) - Required - The contract address. - **value** (bigint) - Required - The value to send, in wei. - **data** (`0x{string}`) - Optional - The ABI-encoded call data. ### Request Example ```typescript const executedCall = await tokenboundClient.execute({ account: '', to: '', value: '', data: '', }) ``` ### Response #### Success Response - **string** - The hash of the transaction that executed the call. ``` -------------------------------- ### getNFT Source: https://github.com/tokenbound/sdk/blob/main/README.md Extracts information about the origin NFT paired with the Tokenbound account. Returns a TokenboundAccountNFT object. ```APIDOC ## getNFT ### Description Extracts information about the origin NFT that is paired with the tokenbound account. Returns a Promise that resolves to a **TokenboundAccountNFT** object. ### Method Not specified (SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **accountAddress** (string) - Required - The Tokenbound account address. ### Request Example ```ts const nft = await tokenboundClient.getNFT({ accountAddress: '', }) ``` ### Response #### Success Response - **TokenboundAccountNFT** - An object containing: - **_tokenContract_** (string) - The token contract address - **_tokenId_** (string) - The token ID - **_chainId_** (string) - The chain ID ``` -------------------------------- ### Deconstruct Tokenbound Account Bytecode Source: https://github.com/tokenbound/sdk/blob/main/README.md Deconstructs the bytecode of a Tokenbound account to extract its constituent parts, such as implementation address, salt, and token details. Returns null if the account is not deployed. ```typescript const segmentedBytecode = await tokenboundClient.deconstructBytecode({ accountAddress: '', }) console.log(segmentedBytecode) ``` -------------------------------- ### Execute Arbitrary Contract Call Source: https://github.com/tokenbound/sdk/blob/main/README.md Performs an arbitrary contract call using a tokenbound account, enabling actions like minting or transferring NFTs. This method replaces the deprecated `executeCall`. ```typescript const executedCall = await tokenboundClient.execute({ account: '', to: '', value: '', data: '', }) console.log(executedCall) ``` ```typescript // Webb's First Deep Field (unlimited mint drop): // https://zora.co/collect/eth:0x28ee638f2fcb66b4106acab7efd225aeb2bd7e8d const zora721 = { abi: zora721DropABI, proxyContractAddress: getAddress('0x28ee638f2fcb66b4106acab7efd225aeb2bd7e8d'), mintPrice: BigInt(0), quantity: 2, tbaAddress: getAddress('0xc33f0A7FcD69Ba00b4e980463199CD38E30d0E5c'), } const encodedMintFunctionData = encodeFunctionData({ abi: zora721.abi, functionName: 'purchase', args: [BigInt(zora721.quantity)], }) const mintToTBATxHash = await tokenboundClient.execute({ account: zora721.tbaAddress, to: zora721.proxyContractAddress, value: zora721.mintPrice * BigInt(zora721.quantity), data: encodedMintFunctionData, }) ``` -------------------------------- ### getAccount Source: https://github.com/tokenbound/sdk/blob/main/README.md Retrieve the tokenbound account address for a given token contract and token ID. ```APIDOC ## getAccount ### Description Retrieves the tokenbound account address associated with a specific token. ### Method `getAccount({ tokenContract: string, tokenId: string })` ### Parameters - `tokenContract` (string) - Required: The address of the token contract. - `tokenId` (string) - Required: The ID of the token. ### Response Example ```json { "example": "0x1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b" } ``` ``` -------------------------------- ### Check Tokenbound Account Signer Authorization Source: https://github.com/tokenbound/sdk/blob/main/README.md Use this method to verify if the active wallet client or signer is authorized to sign transactions for a Tokenbound Account. Note: This method is not available for V2 implementations. ```typescript const isValidSigner = await tokenboundClient.isValidSigner({ account: ZORA721_TBA_ADDRESS, }) console.log('isValidSigner?', isValidSigner) ``` -------------------------------- ### deconstructBytecode Source: https://github.com/tokenbound/sdk/blob/main/README.md Deconstructs the bytecode of a Tokenbound account into its constituent parts. Returns a Promise that resolves to a SegmentedERC6551Bytecode object, or null if the account is not deployed. ```APIDOC ## deconstructBytecode ### Description Deconstructs the bytecode of a Tokenbound account into its constituent parts. ### Method POST ### Endpoint /deconstructBytecode ### Parameters #### Request Body - **accountAddress** (string) - Required - The Tokenbound account address. ### Request Example ```typescript const segmentedBytecode = await tokenboundClient.deconstructBytecode({ accountAddress: '', }) console.log(segmentedBytecode) ``` ### Response #### Success Response (200) - **SegmentedERC6551Bytecode** (object) - Contains the following properties: - **_erc1167Header_** (string) - ERC-1167 Header - **_implementationAddress_** (string) - The ERC-6551 implementation address - **_erc1167Footer_** (string) - ERC-1167 Footer - **_salt_** (string) - The salt value - **_tokenId_** (string) - The token ID - **_tokenContract_** (string) - The token contract address - **_chainId_** (string) - The chain ID #### Error Response - **null** - if the account is not deployed. ``` -------------------------------- ### Transfer ETH from Tokenbound Account Source: https://github.com/tokenbound/sdk/blob/main/README.md Transfers a specified amount of ETH to a recipient address from a Tokenbound account. Returns the transaction hash of the transfer. ```typescript const transferETH = await tokenboundClient.transferETH({ account: '', amount: 0.01, recipientAddress: '', }) console.log(transferERC20) //... ``` -------------------------------- ### transferETH Source: https://github.com/tokenbound/sdk/blob/main/README.md Transfer ETH to a recipient from a Tokenbound account. Returns a Promise that resolves to the transaction hash of the transfer. ```APIDOC ## transferETH ### Description Transfer ETH to a recipient from a Tokenbound account. ### Method POST ### Endpoint /transferETH ### Parameters #### Request Body - **account** (string) - Required - The Tokenbound account address. - **amount** (number) - Required - Amount, in decimal form (eg. 0.01 ETH). - **recipientAddress** (string) - Required - The recipient address or ENS. ### Request Example ```typescript const transferETH = await tokenboundClient.transferETH({ account: '', amount: 0.01, recipientAddress: '', }) console.log(transferERC20) //... ``` ### Response #### Success Response (200) - **transactionHash** (string) - The transaction hash of the transfer. ``` -------------------------------- ### isValidSigner Source: https://github.com/tokenbound/sdk/blob/main/README.md Checks if a tokenbound account has signing authorization. This determines whether the active WalletClient or Signer can be used to sign transactions on behalf of the TBA. This method is not available to V2-based implementations. ```APIDOC ## isValidSigner ### Description Checks if a tokenbound account has signing authorization. This determines whether the active `WalletClient` or `Signer` can be used to sign transactions on behalf of the TBA. NOTE: This method is not available to V2-based implementations ### Parameters #### Path Parameters - **account** (string) - Required - The Tokenbound account address. ### Request Example ```typescript const isValidSigner = await tokenboundClient.isValidSigner({ account: ZORA721_TBA_ADDRESS, }) console.log('isValidSigner?', isValidSigner) ``` ### Response #### Success Response (200) - **isValidSigner** (boolean) - true if the account is a valid signer, otherwise false. ``` -------------------------------- ### transferERC20 Source: https://github.com/tokenbound/sdk/blob/main/README.md Transfer ERC-20 tokens to a recipient from a Tokenbound account. Returns a Promise that resolves to the transaction hash of the transfer. ```APIDOC ## transferERC20 ### Description Transfer ERC-20 tokens to a recipient from a Tokenbound account. ### Method POST ### Endpoint /transferERC20 ### Parameters #### Request Body - **account** (string) - Required - The Tokenbound account address. - **amount** (number) - Required - Amount, in decimal form (eg. 0.1 USDC). - **recipientAddress** (string) - Required - The recipient address or ENS. - **erc20tokenAddress** (string) - Required - The ERC-20 token address. - **erc20tokenDecimals** (number) - Required - The ERC-20 token decimal specification (1-18). ### Request Example ```typescript const transferERC20 = await tokenboundClient.transferERC20({ account: '', amount: 0.1, recipientAddress: '', erc20tokenAddress: '', erc20tokenDecimals: '', }) console.log(transferERC20) //... ``` ### Response #### Success Response (200) - **transactionHash** (string) - The transaction hash of the transfer. ``` -------------------------------- ### Transfer ERC20 Tokens from Tokenbound Account Source: https://github.com/tokenbound/sdk/blob/main/README.md Transfers a specified amount of ERC-20 tokens to a recipient address from a Tokenbound account. Requires token contract address and decimals. Returns the transaction hash. ```typescript const transferERC20 = await tokenboundClient.transferERC20({ account: '', amount: 0.1, recipientAddress: '', erc20tokenAddress: '', erc20tokenDecimals: '', }) console.log(transferERC20) //... ``` -------------------------------- ### Transfer NFT from Tokenbound Account Source: https://github.com/tokenbound/sdk/blob/main/README.md Transfers an NFT (ERC721 or ERC1155) to a specified recipient from a Tokenbound account. Returns the transaction hash upon successful transfer. ```typescript const transferNFT = await tokenboundClient.transferNFT({ account: '', tokenType: 'ERC721', tokenContract: '', tokenId: '', recipientAddress: '', }) console.log(transferNFT) //... ``` -------------------------------- ### transferNFT Source: https://github.com/tokenbound/sdk/blob/main/README.md Transfer an NFT to a recipient from a Tokenbound account. Returns a Promise that resolves to the transaction hash of the transfer. ```APIDOC ## transferNFT ### Description Transfer an NFT to a recipient from a Tokenbound account. ### Method POST ### Endpoint /transferNFT ### Parameters #### Request Body - **account** (string) - Required - The Tokenbound account address. - **tokenType** (string) - Required - Token type: 'ERC721' or 'ERC1155' - **tokenContract** (string) - Required - The address of the token contract. - **tokenId** (string) - Required - The tokenId of the NFT. - **recipientAddress** (string) - Required - The recipient address or ENS. - **amount** (number) - Optional - The number of tokens to send (1155 only). ### Request Example ```typescript const transferNFT = await tokenboundClient.transferNFT({ account: '', tokenType: 'ERC721', tokenContract: '', tokenId: '', recipientAddress: '', }) console.log(transferNFT) //... ``` ### Response #### Success Response (200) - **transactionHash** (string) - The transaction hash of the transfer. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.