0.5.4 • Published 3 days ago
@tokenbound/sdk v0.5.4
@tokenbound/sdk
An SDK for interacting with ERC-6551 accounts using viem.
Installation
$ npm install @tokenbound/sdk
Usage
Instantiate TokenboundClient
Using viem's WalletClient:
import { TokenboundClient } from "@tokenbound/sdk";
import { goerli } from 'viem/chains'
const tokenboundClient = new TokenboundClient({ walletClient, chainId: goerli.id });
or, with a legacy Wagmi / Ethers signer:
import { TokenboundClient } from "@tokenbound/sdk";
const tokenboundClient = new TokenboundClient({ signer, chainId: 1 });
Get account address
import { TokenboundClient } from "@tokenbound/sdk";
import { goerli } from 'viem/chains';
const tokenboundClient = new TokenboundClient({ walletClient, chainId: goerli.id });
const tokenBoundAccount = tokenboundClient.getAccount({
tokenContract: "<token_contract_address>",
tokenId: "<token_id>",
});
Encode call to account
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: "<account_address>",
to: "<recipient_address>",
value: value,
data: data,
});
// Execute encoded call
const hash = await walletClient.sendTransaction(preparedCall);
Custom Implementations
The SDK supports custom 6551 implementations.
If you've deployed your own implementation, you can optionally pass custom configuration parameters when instantiating your TokenboundClient:
import { TokenboundClient } from "@tokenbound/sdk";
const tokenboundClient = new TokenboundClient({
signer: <signer>,
chainId: <chainId>,
implementationAddress: "<custom_implementation_address>",
})
// Custom implementation AND custom registry (uncommon for most implementations)
const tokenboundClientWithCustomRegistry = new TokenboundClient({
signer: <signer>,
chainId: <chainId>,
implementationAddress: "<custom_implementation_address>",
registryAddress: "<custom_registry_address>",
})
### Documentation
See the [Tokenbound docs](https://docs.tokenbound.org/sdk/installation) for complete documentation.
0.5.4
3 days ago
0.5.3-beta.0
21 days ago
0.5.2
25 days ago
0.5.1
2 months ago
0.4.7-beta.0
2 months ago
0.4.7-beta.1
2 months ago
0.4.7-beta.2
2 months ago
0.5.0
2 months ago
0.4.6
2 months ago
0.4.5
6 months ago
0.3.9
7 months ago
0.3.12
7 months ago
0.3.11
7 months ago
0.3.6
8 months ago
0.4.4
6 months ago
0.3.5
9 months ago
0.3.8
8 months ago
0.3.7
8 months ago
0.3.2
10 months ago
0.4.0
7 months ago
0.3.1
10 months ago
0.4.3
7 months ago
0.3.4
9 months ago
0.4.2
7 months ago
0.3.3
9 months ago
0.3.0
11 months ago
0.1.0
1 year ago
0.1.2
1 year ago
0.2.0
1 year ago
0.1.1
1 year ago
0.0.1
1 year ago