GithubHelp home page GithubHelp logo

avocado-sdk's Introduction

@instadapp/avocado

Usage

Install package:

# npm
npm install @instadapp/avocado

# yarn
yarn add @instadapp/avocado

# pnpm
pnpm install @instadapp/avocado

Import:

// ESM
import {} from "@instadapp/avocado";

// CommonJS
const {} = require("@instadapp/avocado");

Examples

import { createSafe } from '@instadapp/avocado'
import { ethers } from 'ethers'

// Should be connected to chainId 634 (https://rpc.avocado.instadapp.io), before doing any transaction
const provider = new ethers.providers.Web3Provider(window.ethereum, "any")

const safe = createSafe( provider.getSigner() )

await safe.getOwnerAddress()

await safe.getSafeAddress()

await safe.sendTransaction({
    to: "0x910E413DBF3F6276Fe8213fF656726bDc142E08E",
    value: 42,
    chainId: 137
})

await safe.sendTransaction({
    to: "0x910E413DBF3F6276Fe8213fF656726bDc142E08E",
    value: 42,
}, 137)

await safe.sendTransactions([
    { to: "0x910E413DBF3F6276Fe8213fF656726bDc142E08E", value: 42 }
    { to: "0x910E413DBF3F6276Fe8213fF656726bDc142E08E", value: 69 }
], 137)

await safe.estimateFee([
    { to: "0x910E413DBF3F6276Fe8213fF656726bDc142E08E", value: 0 }
], 137)

await safe.getSigner().sendTransaction({
    to: "0x69420",
    chainId: 137
})

const signer = safe.getSignerForChainId(137);

await signer.sendTransaction({
    to: "0x69420"
})

const erc20 = new ethers.Contract(
    "0x2791bca1f2de4661ed88a30c99a7a9449aa84174",
    ["function transfer(address to, uint amount) returns (bool)",],
    signer,
)

await erc20.transfer("0x910E413DBF3F6276Fe8213fF656726bDc142E08E", 69420)
import { Wallet, ethers } from "ethers"

const wallet = new Wallet(
    "PK_HERE", 
    new ethers.providers.JsonRpcProvider("https://rpc.avocado.instadapp.io")
)

const safe = createSafe(wallet)

await safe.sendTransaction({
    to: "0x910E413DBF3F6276Fe8213fF656726bDc142E08E",
    value: 0,
    chainId: 137
})
import { setRpcUrls } from '@instadapp/avocado'

setRpcUrls({
    137: "https://polygon-rpc.com",
})

avocado-sdk's People

Contributors

kabbouchi avatar bergben avatar yulafezmesi avatar ishanjain28 avatar thrilok209 avatar yssf-io avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.