Skip to main content

Testnet EVM part

EthersJS

Ethers.js is a compact Javascript library used for interacting with the Ethereum blockchain and other EVM compatible chains.

const  = require("ethers");

// URL of the RPC for the CrossFi Testnet
const providerUrl = "https://rpc.testnet.ms/";

// Creating a provider to interact with the blockchain

const provider = new ethers.JsonRpcProvider(providerUrl);
async function main() `);
}

main().catch((error) => {
console.error("Error connecting to the blockchain:", error);
});

Viem

Viem is a TypeScript library that offers type-safe modules for interacting with the Ethereum and other EVM compatible chains.

import  from 'viem';

export const crossfi = defineChain({
id: 4157,
name: 'CrossFi Testnet',
nativeCurrency: ,
rpcUrls: ,
},
blockExplorers: ,
},
});

const client = createPublicClient({
chain: crossfi,
transport: http(),
});

const blockNumber = await client.getBlockNumber();

export default `Block number: $`;

ThirdWeb

Thirdweb is a developer platform that offers a suite of tools including wallets, contract deployment and libraries to interact with any EVM chain.

Here is a code example using their TypeScript SDK to read the balance of a wallet address:

import  from "@thirdweb-dev/chains";
import from "@thirdweb-dev/sdk";

const sdk = new ThirdwebSDK(CrossfiTestnet, {
clientId: "YOUR_clientId",
});

const getWalletBalance = async () => ;

getWalletBalance();