LearnCard Developer Docs
  • 🚀Get Started
    • 👋Welcome
    • ⭐Who are you?
      • Learners & Employees
      • Traditional Educator
      • Non-Traditional Educator
      • Assessment Provider
      • Employer
      • App Developer & EdTech
      • DAO & Communities
      • Content Creators
      • Research Institutions
      • NGOs & Governments
      • Plugfest Partner
        • Guide for Interop Issuers
          • 🤽Creating an Interop Issuer
        • Guide for Interop Wallets
    • Protocol Overview
      • The Internet of Education
      • The Learning Economy
      • Learner & Employee Privacy
      • 22nd Century Education
      • The Open Credential Network
      • PVCs
  • 🔰LearnCard SDK
    • What is LearnCard?
      • Why a Universal Wallet?
      • Architectural Patterns
      • Production Deployment Guide
      • Troubleshooting Guide
    • LearnCard Core
      • Quick Start
        • Create New Credentials
          • Creating Verifiable Credentials for LearnCard
          • Achievement Types and Categories
          • Custom Types
          • Understanding Boosts
          • Creating Boost Credentials
        • Sign & Send Credentials
        • Accept & Verify Credentials
        • Share & Present Credentials
      • Construction
        • Managing Seed Phrases
        • initLearnCard
        • DIDKit
        • learnCardFromSeed
        • emptyLearnCard
        • IDX Config
      • Control Planes
        • ID
        • Read
        • Store
        • Index
        • Cache
        • Context
      • Plugins
        • Adding Plugins
        • Official Plugins
          • Dynamic Loader
          • Crypto
          • DIDKit
          • DID Key
          • VC
            • Expiration Sub-Plugin
          • VC Resolution
          • VC-Templates
          • VC-API
          • Ceramic
          • IDX
          • VPQR
          • Ethereum
          • CHAPI
          • LearnCard Network
          • LearnCloud
          • LearnCard
          • Claimable Boosts
        • Writing Plugins
          • The Simplest Plugin
          • The Plugin Type
          • The LearnCard Type
          • Implementing Control Planes
          • Implementing Methods
          • The Implicit LearnCard
          • Depending on Plugins
          • Private Fields
          • Publishing a Plugin to NPM
      • URIs
      • CHAPI
        • ⭐CHAPI Wallet Setup Guide
        • ↔️Translating to CHAPI documentation
        • 🖥️Demo Application
        • 🔰Using LearnCard to Interact with a CHAPI Wallet
        • 📝Cheat Sheets
          • Issuers
          • Wallets
      • LearnCard UX
        • Quick Start
        • Components
          • Verifiable Credentials
            • VC Thumbnail
            • VC Thumbnail, Mini
          • LearnCards
            • LearnCard Front
            • LearnCard Back
        • API
      • LearnCard Bridge
      • API
      • Migration Guide
    • LearnCard Network
      • LearnCard Network API
        • Authentication
        • Auth Grants and API Tokens
        • Profile
        • Credentials
        • Boosts
        • Presentations
        • Storage
        • Signing Authorities
        • Notifications
        • API Docs
        • Launch Your Own Network
      • 🔌Connect Your Application
    • ConsentFlow
      • Setting Up ConsentFlow with an Independent Network
    • GameFlow
      • Sending xAPI Statements
        • xAPI URIs
      • Reading xAPI Statements
        • Advanced xAPI Statement Queries
      • Consentful "Claim Later" Flow
  • 🚀Applications
    • LearnCard
    • SuperSkills!
      • SuperSkills! SDK
        • Digital Wallets
        • Issuing into SuperSkills!
        • 🦸Creating a SuperSkills! Issuer
    • Metaversity
    • Admin Dashboard
  • 🔗Resources
    • Github
    • Community
    • 💅Custom Development
    • Contact Our Team
    • Learning Economy
  • 🤖LearnCard Services
    • LearnCard CLI
    • Discord Bot
    • Metamask Snap
  • 💸LearnBank SDK
    • Why LearnBank?
  • 📊LearnGraph SDK
    • Why LearnGraph?
Powered by GitBook
On this page
  • Installation
  • Instantiation
  • Methods

Was this helpful?

  1. LearnCard SDK
  2. LearnCard Core
  3. Plugins
  4. Official Plugins

Ethereum

A plugin for interacting with the Ethereum blockchain

PreviousVPQRNextCHAPI

Last updated 1 year ago

Was this helpful?

Installation

pnpm i @learncard/ethereum-plugin

Instantiation

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 type, which can be a 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)

Methods

getEthereumAddress()

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

      learnCard.getBalance('USDC')

      • 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()

getCurrentNetwork()

changeNetwork(_network)

Changes the current Ethereum network

addInfuraProjectId(infuraProjectId)

Add or change the Infura project ID

  • infuraProjectId - string

    • The new infura project ID that you wish to use

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

If not provided, the will be used.

Same as

Same as

Returns the current Ethereum network (type: )

_network -

🔰
Networkish
Network
Infura
default ethers provider
getBalance's symbolOrAddress
getBalance's symbolOrAddress
Networkish
Networkish