chaingate
Version:
Multi-chain cryptocurrency SDK for TypeScript — unified API for Bitcoin, Ethereum, Litecoin, Dogecoin, Bitcoin Cash, Polygon, Arbitrum, and any EVM-compatible chain. Create wallets, query balances, send transactions, and manage tokens and NFTs across UTXO
39 lines (38 loc) • 1.44 kB
TypeScript
/**
* Minimal ABI encoding utilities for ERC-20, ERC-721 and ERC-1155 transfer
* calldata.
*
* All functions return a hex string with `0x` prefix ready to be used as
* transaction `data`.
*/
/**
* Encodes the calldata for an ERC-20 `transfer(address to, uint256 amount)` call.
*
* @param to - Recipient address.
* @param amount - Amount of tokens in the token's smallest unit (e.g. wei for 18-decimal tokens).
* @returns Hex string with `0x` prefix.
*/
export declare function encodeErc20Transfer(to: string, amount: bigint): string;
/**
* Encodes the calldata for an ERC-721
* `safeTransferFrom(address from, address to, uint256 tokenId)` call.
*
* @param from - Current owner address.
* @param to - Recipient address.
* @param tokenId - The NFT token ID.
* @returns Hex string with `0x` prefix.
*/
export declare function encodeErc721SafeTransferFrom(from: string, to: string, tokenId: bigint): string;
/**
* Encodes the calldata for an ERC-1155
* `safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes data)` call.
*
* The `data` parameter is always empty (`0x`).
*
* @param from - Current owner address.
* @param to - Recipient address.
* @param tokenId - The token ID.
* @param amount - Number of tokens to transfer.
* @returns Hex string with `0x` prefix.
*/
export declare function encodeErc1155SafeTransferFrom(from: string, to: string, tokenId: bigint, amount: bigint): string;