A plugin for interacting with the Ethereum blockchain


pnpm i @learncard/ethereum-plugin


To use this plugin, you must include an ethereumConfig object as a part of the LearnCardConfig parameter for initLearnCard

const learnCard = await initLearncard({ 
    seed: privateKey, 
    // ...
    ethereumConfig: {
        network: 'mainnet',
        infuraProjectId: 'abc123'

network (optional)

The Ethereum network to connect to. This is an ethers Networkish type, which can be a Network object, the name of a network as a string, or the chain ID of a network as a number.

Defaults to 'mainnet' if not provided

infuraProjectId (optional)

The Infura project ID that you would like to use to access the Ethereum network.

If not provided, the default ethers provider will be used.



Returns the Ethereum public address associated with this wallet

async getBalance(symbolOrAddress)

Returns the token balance for this wallet for the given symbol or token address

await learnCard.getBalance('ETH')

  • symbolOrAddress - string (optional)

    • The ERC20 token address for the token you wish to check the balance of

      learnCard.getBalance('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48') // USDC on mainnet

    • The token symbol for the token you wish to check the balance of


      • Note: this will only work if the given symbol is recognized.

    • Defaults to 'ETH' if omitted

async getBalanceForAddress(walletAddress, symbolOrAddress)

Returns the token balance for the given wallet address for the given symbol/token address

await learnCard.getBalanceForAddress('0xAddressToCheck', 'DAI')

  • walletAddress - string

    • The public address you wish to check the balance for

  • symbolOrAddress - string (optional)

async transferTokens(tokenSymbolOrAddress, amount, toAddress)

Transfers tokens from this wallet to another wallet. Returns the transaction hash.

await wallet.transferTokens('USDC', 2.2, '0xAddressToSendTo')

  • tokenSymbolOrAddress - string

  • amount - number

    • The number of tokens you wish to transfer

  • toAddress - string

    • The address that you wish to send tokens to

async getGasPrice()

Get the current gas price for the network

await wallet.getGasPrice()


Returns the current Ethereum network (type: Networkish)


Changes the current Ethereum network


Add or change the Infura project ID

  • infuraProjectId - string

    • The new infura project ID that you wish to use

Last updated