1.1.2 • Published 11 months ago

ethers-suave v1.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

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.

1.1.1

11 months ago

1.1.2

11 months ago

1.1.0

11 months ago

1.0.4

1 year ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago