Parte EVM da Mainnet
EthersJS
Ethers.js é uma biblioteca JavaScript compacta usada para interagir com a blockchain Ethereum e outras redes compatíveis com EVM.
const = require("ethers");
// URL of the RPC for the CrossFi Mainnet
const providerUrl = "https://rpc.mainnet.ms/";
// Creating a provider to interact with the blockchain
const provider = new ethers.JsonRpcProvider(providerUrl);
async function main() `);
}
main().catch((error) => {
\tconsole.error("Error connecting to the blockchain:", error);
});
Viem
Viem é uma biblioteca TypeScript que oferece módulos com tipagem segura para interagir com a blockchain Ethereum e outras redes compatíveis com EVM.
import from 'viem';
export const crossfi = defineChain({
id: 4158,
name: 'CrossFi Mainet',
nativeCurrency: ,
rpcUrls: ,
},
blockExplorers: ,
},
});
const client = createPublicClient({
chain: crossfi,
transport: http(),
});
const blockNumber = await client.getBlockNumber();
export default `Block number: $`;