Building On Magma
Web3 Clients

Web3 Clients

Viem

You can connect to Magma using a new viem public client with the Magma network.

import { createPublicClient, custom } from "viem"
import { magma } from "@/lib/viem.chains

const publicClient = createPublicClient({
        chain: magma,
        batch: {
            multicall: {
                wait: 8
            }
        },
        transport: custom(window.ethereum);
    })

EthersJS

Connect to Magma using a new ethers.js JsonRpcProvider object:

const ethers = require('ethers'); // ethers v6
const url = 'https://turbo.magma-rpc.com';
const provider = new ethers.JsonRpcProvider(url);

Web3Js

Connect to Magma by using a new web3.js Web3 object:

const { Web3 } = require('web3')

const web3 = new Web3('https://turbo.magma-rpc.com')