coinbase / coinbase-sdk-nodejs

Other
74 stars 29 forks source link

[wip] Support contract invocations #195

Closed alex-stone closed 2 months ago

alex-stone commented 2 months ago

What changed? Why?

Example usage

import { Coinbase, Wallet } from "./src/index";

Coinbase.configureFromJson();

const wallet = await Wallet.create();

await wallet.faucet();

const abi = [
  {
    inputs: [ { internalType: 'address', name: 'recipient', type: 'address' } ],
    name: 'mint',
    outputs: [ { internalType: 'uint256', name: '', type: 'uint256' } ],
    stateMutability: 'payable',
    type: 'function'
  }
]

const contractInvocation = await wallet.getDefaultAddress.invokeContract({
  abi,
  method: "mint",
  contractAddress: '0xa82aB8504fDeb2dADAa3B4F075E967BbE35065b9',
  args: ['0x475d41de7A81298Ba263184996800CBcaAD73C0b']
});

await contractInvocation.wait();

Qualified Impact