Skip to main content

Token Bound Accounts (ERC-6551)

Create smart contract wallets owned by NFTs. Each NFT gets its own address that can hold assets, execute transactions, and interact with other contracts.

Create a TBA for an NFT

const tba = await urblock.tba.create({
token_id: "tok_abc123", // ERC-721 contract
nft_token_id: "1", // token ID
network: "polygon_amoy",
idempotency_key: "tba-001",
});

console.log(tba.account_address); // deterministic address

Predict Address Before Creation

const prediction = await urblock.tba.predictAccount("tba_abc123");
console.log(prediction.address); // same deterministic address

Execute a Call

The NFT owner can execute arbitrary calls from the TBA:

const tx = await urblock.tba.execute("tba_abc123", {
to: "0xTokenContract...",
value: "0",
data: "0xa9059cbb...", // encoded transfer call
idempotency_key: "tba-exec-001",
});

Batch Execute

Execute multiple calls in one transaction:

const tx = await urblock.tba.executeBatch("tba_abc123", {
calls: [
{ to: "0xToken1...", value: "0", data: "0x..." },
{ to: "0xToken2...", value: "0", data: "0x..." },
],
idempotency_key: "tba-batch-001",
});

Query TBA State

Get the Owning NFT

const token = await urblock.tba.getToken("tba_abc123");
console.log(token.chain_id);
console.log(token.token_contract);
console.log(token.token_id);

Get Balance

const balance = await urblock.tba.getBalance("tba_abc123");
console.log(balance.eth_balance); // native token balance in wei

Get State (Nonce)

const state = await urblock.tba.getState("tba_abc123");
console.log(state.state); // nonce / execution count

Find TBA by NFT

const tba = await urblock.tba.getByNft("tok_abc123", "1");
console.log(tba.account_address);

Verify Signatures (EIP-1271)

const result = await urblock.tba.isValidSignature(
"tba_abc123",
"0xMessageHash...",
"0xSignature...",
);
console.log(result.is_valid);

Use Cases

  • NFT inventory — NFTs that own other NFTs and tokens
  • On-chain identity — a portable wallet tied to a profile NFT
  • Gaming — characters with their own inventories and balances
  • DAOs — NFT-gated treasury management

Next Steps