Git Product home page Git Product logo

ethers-suave's Introduction

ethers-suave

A typescript library, built on top of ethers.js, for interacting with Suave confidential requests.

Usage

Send confidential request with ABI

const provider = new SuaveProvider(kettleUrl)
const wallet = new SuaveWallet(pk, provider)

const StoreContract = new SuaveContract(storeContractAdd, storeABI, wallet)
const milkLiters = 2
const milkType = 1 // 'whole'
// Non-confidential methods are called as usual
const milkPrice = await StoreContract.milkSpotPrice(milkType)
const confidentialInputs = createPaymentBundle(milkPrice, milkLiters)
// Response is ConfidentialTransactionResponse 
const res = await StoreContract.buyMilk.sendCCR(milkType, milkLiters, { confidentialInputs })
// Receipt is a normal EVM transaction receipt
const receipt = await res.wait()

Create a confidential request

const ccr = await StoreContract.buyMilk.prepareCCR(milkType, milkLiters, { confidentialInputs }) 

Get a confidential request

const tx = await provider.getConfidentialTransaction('0xafac2...')

Send confidential request without ABI

const crecordlike = {
    data: '0x966a0212...',
    to: storeContractAdd
}
const confidentialTxResponse = await wallet.sendCCR(crecordlike, confidentialInputs)

Populate confidential record without ABI

const crecordlike = {
    data: '0x966a0212...',
    to: storeContractAdd
}
const crecord = await wallet.populateCRecord(crecordlike)

Dev Setup

Install dependencies

yarn install --dev

Test

yarn test

Contributions

Any contributions are welcome! Please submit a PR or an issue.

ethers-suave's People

Contributors

halo3mic avatar

Stargazers

brock smedley avatar  avatar Chris Maree avatar Zane Peycke avatar Shun Kakinoki avatar Michael Demarais avatar Turan Vural avatar

Watchers

Michael Demarais avatar  avatar

ethers-suave's Issues

On RPC return parsing fails for non-evm errors

For example, if there is an error such as "wrong kettle address" this error will occur:

TypeError: Cannot read properties of null (reading 'groups')
at SuaveContract._SuaveContract_formatSubmissionError (node_modules/ethers-suave/src/wrappers.ts:104:36)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async AsyncFunction.extendedMethod.sendConfidentialRequest (node_modules/ethers-suave/src/wrappers.ts:81:22)

Add `eth_kettleAddress`

With access to the kettle address, the user doesn't need to provide the kettle address themselves anymore.

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.