LearnCard Documentation
GithubStatusSupportLaunch App
  • 🚀Introduction
    • What is LearnCard?
    • Use Cases & Possibilities
    • Ecosystem Architecture
  • ⚡Quick Start
    • Setup & Prerequisites
    • Your First Integration
  • 📚Tutorials
    • Create a Credential
    • Create a Boost
    • Create a ConsentFlow
    • Create a Connected Website
    • Send xAPI Statements
    • Listen to Webhooks
  • ✅How-To Guides
    • Verify My Issuer
    • Connect Systems
      • Connect a Website
      • Connect a Game
    • Implement Flows
      • Claim Data after Guardian Consent
      • Connect via CHAPI
        • ⭐CHAPI Wallet Setup Guide
        • ↔️Translating to CHAPI documentation
        • 🖥️Demo Application
        • 🔰Using LearnCard to Interact with a CHAPI Wallet
        • 📝Cheat Sheets
          • Issuers
          • Wallets
    • Deploy Infrastructure
      • Remote Key Management
      • Generate API Tokens
      • Signing Authority
      • Connect to Independent Network
      • Build a Plugin
  • 🛠️SDKs & API Reference
    • LearnCard Wallet SDK
      • Authentication
      • Usage Examples
      • SDK Reference
      • Plugin API Reference
      • Integration Strategies
      • Deployment
      • Troubleshooting
      • Changelog
    • LearnCloud Network API
      • Authentication
      • Usage Examples
      • Architecture
      • Notifications & Webhooks
      • Profiles
      • Profile Managers
      • Credentials
      • Boosts
      • Presentations
      • Storage
      • Contracts
      • DID Metadata
      • Claim Hooks
      • Auth Grants
      • Utilities
      • Models
      • OpenAPI
    • LearnCloud Storage API
      • Authentication
      • Usage Examples
      • Architecture
      • Storage
      • Index
      • User
      • Custom Storage
      • Utilities
      • Models
      • xAPI Reference
    • Plugins
      • Crypto
      • DIDKit
      • DID Key
      • Dynamic Loader
      • VC
        • Expiration Sub-Plugin
      • VC-Templates
      • VC-API
      • Ceramic
      • IDX
      • VPQR
      • Ethereum
      • CHAPI
      • LearnCard Network
      • LearnCloud
      • LearnCard
      • Simple Signing
      • Claimable Boosts
    • LearnCard CLI
  • 🧠Core Concepts
    • Identities & Keys
      • Decentralized Identifiers (DIDs)
      • Seed Phrases
      • Network Profiles
      • Signing Authorities
      • Trust Registries
    • Credentials & Data
      • Verifiable Credentials (VCs)
      • Credential Lifecycle
      • Schemas, Types, & Categories
      • Building Verifiable Credentials
      • Boost Credentials
      • Getting Started with Boosts
      • Credential URIs
      • xAPI Data
      • General Best Practices & Troubleshooting
    • Consent & Permissions
      • ConsentFlow Overview
      • Consent Contracts
      • User Consent & Terms
      • Consent Transactions
      • Auto-Boosts
      • Writing Consented Data
      • Accessing Consented Data
      • GameFlow Overview
    • Network & Interactions
      • Network Vision & Principles
      • Key Network Procedures
      • Core Interaction Workflows
    • Architecture & Principles
      • Control Planes
      • Plugin System
      • Auth Grants and API Tokens
  • 🔗Development
    • Contributing
Powered by GitBook
On this page
  • Installation
  • Instantiation
  • Methods

Was this helpful?

  1. SDKs & API Reference
  2. Plugins

Ethereum

A plugin for interacting with the Ethereum blockchain

PreviousVPQRNextCHAPI

Last updated 23 days 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