Skip to main content
To use paymaster you simply need to pass a ERC-20 token that you want a user to pay a gas with Currently paymaster is integrated to several operations with the SDK:
  1. Send a transaction
  2. Deposit funds to a DeFi opportunity (earn() method)
  3. Withdraw funds to a DeFi opportunity (withdraw() method)

How to use a paymaster?

Here is a quick exmaple how to sponsor gas during the depositing a user funds to DeFi opportunity
1

Init SDK

import { MyceliumSDK } from '@mycelium-sdk/core';


const sdk = await MyceliumSDK.init({
    apiKey:
      "sk_e010bc44958665229cb89634448f81f532231ce131c4eb98816eadcb2e6ed7fa47",
    chainId: 8453,
    protocolsSecurityConfig: {
      riskLevel: "low",
    },
  });
2

Get a vault to depoist

const vaults = await sdk.protocols.getBestVaults()
3

Get or create a user wallet

const wallet = await this.sdk.wallet.createAccount()
4

Deposit using paymaster

const USDC_TOKEN_ADDRESS = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"

const txnHash = await wallet.earn(
	selectedVault.vaultInfo, 
	amountToDeposit, 
	{
      paymasterToken: USDC_TOKEN_ADDRESS,
    }
);