Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tokenbound/sdk

Package Overview
Dependencies
Maintainers
0
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tokenbound/sdk

An SDK for interacting with [ERC-6551 accounts](https://eips.ethereum.org/EIPS/eip-6551) using viem.

  • 0.5.5
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
462
decreased by-37.57%
Maintainers
0
Weekly downloads
 
Created
Source

@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.

FAQs

Package last updated on 22 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc