Conla Docs
  • Greetings to Conla Docs
  • About Conla
    • What is Conla?
    • Consumer chain on TON
    • Technical Features
    • Architecture
  • Users
    • Onboarding
      • Install MetaMask
      • Add to MetaMask
      • Faucet tTON
    • Community
  • Developers
    • Quick start
      • Connect to Conla
      • Faucet tBTC
    • AA wallet & Paymaster
      • SDK integration
      • Conla Wallet
    • dApp
      • Write a contract
      • Deploy with Foundry
      • Deploy with Hardhat
      • Verify a contract
    • Run a Conla Node
    • Conla Verifier
  • Reference
    • Sovereign SDK
    • reth
    • Celestia
    • ERC-4337: Account Abstraction
Powered by GitBook
On this page
  • Installation
  • LowLevel API
  • SimpleAccountAPI
  • High-Level Provider API
  1. Developers
  2. AA wallet & Paymaster

SDK integration

PreviousAA wallet & PaymasterNextConla Wallet

Last updated 8 months ago

Installation

npm i aa-conla-sdk

NPM package link:

This package provides 2 APIs for using UserOperations:

  • Low-level "walletAPI"

  • High-level Provider

Conla bundler
Entry point address: 0x3bFc49341Aae93e30F6e2BE5a7Fa371cEbd5bea4
Bundler rpc url: https://aa-bundler.conla.com/rpc

LowLevel API

BaseWalletAPI

An abstract base-class to create UserOperation for a contract wallet.

SimpleAccountAPI

An implementation of the BaseWalletAPI, for the SimpleWallet sample of account-abstraction.

owner = provider.getSigner()
const dest = ethers.Wallet.createRandom()
const paymasterAPI = new PaymasterAPI(entryPointAddress, bundlerUrl)
const accountAPI = new SimpleAccountAPI({
  provider: provider,
  entryPointAddress: entryPointAddress,
  owner: owner,
  factoryAddress: factoryAddress,
  paymasterAPI: paymasterAPI,
})

const gasPrice = await provider.getGasPrice()
const value = parseEther('0.1')

const op = await accountAPI.createSignedUserOp({
  target: dest.address,
  data: "0x",
  value: value,
  maxFeePerGas: gasPrice,
  maxPriorityFeePerGas: gasPrice,
})

const packeUserOp = await packUserOp(op)

const tx = await accountAPI.sendHandlerOps([packeUserOp])
console.log("tx hash: ", tx.hash)

High-Level Provider API

A simplified mode that doesn't require a different wallet extension. Instead, the current provider's account is used as wallet owner by calling its "Sign Message" operation.

This can only work for wallets that use an EIP-191 ("Ethereum Signed Message") signature (like our sample SimpleWallet) Also, the UX is not great (the user is asked to sign a hash, and even the wallet address is not mentioned, only the signer)

import { wrapProvider } from 'aa-conla-sdk'

//use this account as wallet-owner (which will be used to sign the requests)
const aaSigner = provider.getSigner()
const paymasterAPI = new PaymasterAPI(entryPointAddress, bundlerUrl)

const config = {
  chainId: await provider.getNetwork().then(net => net.chainId),
  entryPointAddress,
  bundlerUrl: 'bundlerUrl',
  paymasterAPI
} 
const aaProvider = await wrapProvider(provider, config, aaSigner)
const walletAddress = await aaProvider.getSigner().getAddress()

// send some eth to the wallet Address: wallet should have some balance to pay for its own creation, and for calling methods.

const myContract = new Contract(abi, aaProvider)

// this method will get called from the wallet address, through account-abstraction EntryPoint
await myContract.someMethod()
npm: aa-conla-sdknpm
Logo