A utility package that simplifies EVM development on The Root Network.
npm i @futureverse/evm
import {
collectionIdToERC721Address,
ERC721_PRECOMPILE_ABI,
} from '@futureverse/evm';
import { createPublicClient, http } from 'viem';
import { root } from 'viem/chains';
// Create a viem client
const client = createPublicClient({
chain: root,
transport: http(),
});
// `owner` is automatically typed as `Address`
const owner = await client.readContract({
address: collectionIdToERC721Address(17508)
abi: ERC721_PRECOMPILE_ABI,
functionName: 'ownerOf', // Strongly typed ABI gives you autocomplete for function names
args: [3248n] // Gives type errors for args which don't match the ABI function inputs
})
ABI | Description |
---|---|
ERC20_ABI |
ABI for the ERC-20 standard |
ERC721_ABI |
ABI for the ERC-721 standard |
ERC1155_ABI |
ABI for the ERC-1155 standard |
NFT_PRECOMPILE_ABI |
ABI for the nft pallet |
SFT_PRECOMPILE_ABI |
ABI for the sft pallet |
FEE_PROXY_PRECOMPILE_ABI |
ABI for feeProxy pallet |
FUTUREPASS_PRECOMPILE_ABI |
ABI for a futurepass account |
FUTUREPASS_REGISTRAR_PRECOMPILE_ABI |
ABI for futurepass pallet |
DEX_PRECOMPILE_ABI |
ABI for the dex pallet |
OWNABLE_ABI |
ABI for the ownable interface |
MARKETPLACE_PRECOMBILE_ABI |
ABI for the marketplace pallet |
MULTICALL3_ABI |
ABI for the multicall3 contract |
Address | Description |
---|---|
NFT_PRECOMPILE_ADDRESS: string |
Precompile address for nft pallet |
SFT_PRECOMPILE_ADDRESS: string |
Precompile address for sft pallet |
FUTUREPASS_REGISTRAR_PRECOMPILE_ADDRESS: string |
Precompile address for futurepass pallet |
PEG_PRECOMPILE_ADDRESS: string |
Precompile address for erc20Peg and nftPeg pallets |
DEX_PRECOMPILE_ADDRESS: string |
Precompile address for dex pallet |
FEE_PROXY_PRECOMPILE_ADDRESS |
Precompile address for feeProxy pallet |
MARKETPLACE_PRECOMPILE_ADDRESS |
Precompile address for marketplace pallet |
MULTICALL3_ADDRESS |
Address for multicall3 contract |
RNS_REGISTRAR_ADDRESS_ROOT |
Address for rnsRegistrar contract on Root |
RNS_REGISTRAR_ADDRESS_PORCINI |
Address for rnsRegistrar contract on Porcini |
/**
* Converts an asset's assetId to a contract address
* @param assetId - The assetId we are converting
* @returns The contract address
*/
function assetIdToERC20Address(assetId: string | number): `0x${string}`;
/**
* Converts an NFT collectionId to a contractAddress
* @param collectionId - The collectionId we are converting
* @returns The contract address
*/
function collectionIdToERC721Address(
collectionId: string | number
): `0x${string}`;
/**
* Converts an SFT collectionId to a contractAddress
* @param collectionId - The collectionId we are converting
* @returns The contract address
*/
function collectionIdToERC1155Address(
collectionId: string | number
): `0x${string}`;
/**
* Converts a contract address back to it's native ID (collection ID or asset
* ID) if possible
* @param contractAddress - The address we are checking
* @returns NativeId or `null` when conversion failed
*/
function contractAddressToNativeId(contractAddress: Address): number | null;
/**
* Retrieves whether address is a Futurepass
* @param address - The address we are checking
* @returns Whether it's a futurepass or not
*/
function isFuturepass(address: Address): boolean;