Skip to main content

Contracts & NFTs API

The Contracts and NFTs API provides 9 methods for deploying smart contracts, reading and writing contract state, and managing NFTs.

Contract Methods

MethodParametersReturnsDescription
getUserContracts(options?)options?: ContractListOptionsApiResponse<Contract[]>Lists contracts deployed by the authenticated user.
getContractDetails(contractAddress, chainId)contractAddress: string, chainId: stringApiResponse<Contract>Returns metadata and ABI for a deployed contract.
readContract(params)params: ContractReadParamsApiResponse<unknown>Calls a read-only (view/pure) function on a contract.
writeContract(params)params: ContractWriteParamsApiResponse<ContractWriteResult>Sends a state-changing transaction to a contract.
deployContract(params)params: ContractDeployParamsApiResponse<ContractDeployResult>Deploys a compiled contract to a chain.

NFT Methods

MethodParametersReturnsDescription
getUserNFTs(walletAddress, options?)walletAddress: string, options?: NFTListOptionsApiResponse<NFT[]>Lists NFTs owned by a wallet address.
getNFTDetails(contractAddress, tokenId, chainId)contractAddress: string, tokenId: string, chainId: stringApiResponse<NFT>Returns metadata for a specific NFT.
getNFTCollection(contractAddress, chainId, options?)contractAddress: string, chainId: string, options?: NFTCollectionOptionsApiResponse<NFTCollection>Returns collection-level metadata and token list.
transferNFT(params)params: NFTTransferParamsApiResponse<NFTTransfer>Transfers an NFT from one address to another.

Types

Contract

interface Contract {
address: string;
chainId: string;
name: string;
/** Contract type / standard (e.g. "ERC20", "ERC721", "custom"). */
type: string;
abi: Record<string, unknown>[];
deployedBy: string;
deployTxHash: string;
blockNumber: number;
verified: boolean;
createdAt: string;
}

ContractListOptions

interface ContractListOptions {
chainId?: string;
type?: string;
limit?: number;
cursor?: string;
}

ContractReadParams

interface ContractReadParams {
/** Contract address. */
contractAddress: string;
/** Chain ID. */
chainId: string;
/** Function name to call. */
functionName: string;
/** ABI of the contract (or at least the target function). */
abi: Record<string, unknown>[];
/** Arguments to pass to the function. */
args?: unknown[];
}

ContractWriteParams

interface ContractWriteParams {
/** Contract address. */
contractAddress: string;
/** Chain ID. */
chainId: string;
/** Function name to call. */
functionName: string;
/** ABI of the contract (or at least the target function). */
abi: Record<string, unknown>[];
/** Arguments to pass to the function. */
args?: unknown[];
/** Wallet address sending the transaction. */
from: string;
/** Native value to send (in wei). */
value?: string;
/** Gas limit override. */
gasLimit?: string;
}

ContractWriteResult

interface ContractWriteResult {
txId: string;
txHash?: string;
status: 'queued' | 'submitted' | 'confirmed' | 'failed';
}

ContractDeployParams

interface ContractDeployParams {
/** Chain to deploy on. */
chainId: string;
/** Compiled bytecode (hex string). */
bytecode: string;
/** Contract ABI. */
abi: Record<string, unknown>[];
/** Constructor arguments. */
constructorArgs?: unknown[];
/** Wallet address deploying the contract. */
from: string;
/** Optional: human-readable name for dashboard tracking. */
name?: string;
}

ContractDeployResult

interface ContractDeployResult {
txId: string;
txHash?: string;
contractAddress?: string;
status: 'queued' | 'submitted' | 'confirmed' | 'failed';
}

NFT

interface NFT {
contractAddress: string;
tokenId: string;
chainId: string;
name: string;
description?: string;
imageUrl?: string;
animationUrl?: string;
attributes: { trait_type: string; value: string | number }[];
owner: string;
standard: 'ERC721' | 'ERC1155';
balance?: string;
}

NFTListOptions

interface NFTListOptions {
chainId?: string;
contractAddress?: string;
limit?: number;
cursor?: string;
}

NFTCollection

interface NFTCollection {
contractAddress: string;
chainId: string;
name: string;
symbol: string;
description?: string;
imageUrl?: string;
totalSupply: string;
standard: 'ERC721' | 'ERC1155';
floorPrice?: string;
tokens: NFT[];
hasMore: boolean;
cursor?: string;
}

NFTCollectionOptions

interface NFTCollectionOptions {
limit?: number;
cursor?: string;
}

NFTTransferParams

interface NFTTransferParams {
contractAddress: string;
tokenId: string;
chainId: string;
from: string;
to: string;
/** For ERC1155, the quantity to transfer. Default 1. */
amount?: string;
}

NFTTransfer

interface NFTTransfer {
txId: string;
txHash?: string;
status: 'queued' | 'submitted' | 'confirmed' | 'failed';
contractAddress: string;
tokenId: string;
from: string;
to: string;
}

Examples

Read a Contract

const res = await engine.readContract({
contractAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
chainId: 'ethereum',
functionName: 'balanceOf',
abi: [
{
name: 'balanceOf',
type: 'function',
stateMutability: 'view',
inputs: [{ name: 'account', type: 'address' }],
outputs: [{ name: '', type: 'uint256' }],
},
],
args: ['0xABC...'],
});

if (res.success) {
console.log('USDC balance (raw):', res.data);
}

Write to a Contract

const res = await engine.writeContract({
contractAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
chainId: 'ethereum',
functionName: 'transfer',
abi: [
{
name: 'transfer',
type: 'function',
stateMutability: 'nonpayable',
inputs: [
{ name: 'to', type: 'address' },
{ name: 'amount', type: 'uint256' },
],
outputs: [{ name: '', type: 'bool' }],
},
],
args: ['0xDEF...', '1000000'],
from: '0xABC...',
});

if (res.success && res.data) {
console.log('Transaction queued:', res.data.txId);
}

Deploy a Contract

const res = await engine.deployContract({
chainId: 'ethereum',
bytecode: '0x6080604052...',
abi: compiledAbi,
constructorArgs: ['My Token', 'MTK', 18],
from: '0xABC...',
name: 'MyToken',
});

if (res.success && res.data) {
console.log('Deploy tx:', res.data.txId);
// Poll until confirmed to get the contract address
}

List NFTs

const res = await engine.getUserNFTs('0xABC...', {
chainId: 'ethereum',
limit: 20,
});

if (res.success && res.data) {
for (const nft of res.data) {
console.log(`${nft.name} (#${nft.tokenId}) - ${nft.contractAddress}`);
}
}

Transfer an NFT

const res = await engine.transferNFT({
contractAddress: '0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D',
tokenId: '1234',
chainId: 'ethereum',
from: '0xABC...',
to: '0xDEF...',
});

if (res.success && res.data) {
console.log('NFT transfer queued:', res.data.txId);
}

Next Steps