SDK
Currently only the Ethereum holesky test network and AO are supported, and the Ethereum main network and other networks will be gradually supported in the future.
Overview
The bavo-network-sdk helps developers use BAVO Network, which provides trustless and confidential computing capabilities. You can learn more about Introduction.
Quick Start
Demos
Usage
Installation
Install package by npmx
import wasm
Introduce lhe.js
into the HTML file as follows:
If you meet the following error in your browser's console:
You can refer to project using vite.
Getting Started
Utils
Generate Key
Generate public-private key pairs for submitting tasks and retrieving task results.
Example
BAVONetworkContractClient
Import Client
Instantiate Client
The constructor for the bavoNetworkContractClient
.
Parameters
chainName: The blockchain the client wants to connect to. Learn more about ChainName
wallet: The wallet that interacts with the blockchain.
storageType (optional): The storage option the client wants to use for data. The default is
StorageType.ARSEEDING
. Learn more about StorageType
Note:
By default,
StorageType
isARWEAVE
whenchainName
isao
, andARSEEDING
whenchainName
isholesky
orethereum
.When using ARSEEDING as storage, user need to deposit ETH to EverPay to cover storage, computation, data, and other costs. You can learn more about EverPay at:
Homepage: https://everpay.io/
Docs: https://docs.everpay.io/en/docs/guide/overview
Deposit: https://app.everpay.io/deposit/ethereum-eth-0x0000000000000000000000000000000000000000
When using ARWEAVE as storage, user will pay AR to cover storage, computation, data, and other costs by ArConnect.
ao
ARWEAVE
window.arweaveWallet(ArConnect)
holesky
ARSEEDING
window.ethereum(metamask)
ethereum
ARSEEDING
window.ethereum(metamask)
Returns
Example
Upload Data
Uploading data to the storage chain.
Parameters
data: The data to be uploaded, which should be of type
Uint8Array
.dataTag: The data's metadata object. Note: Please use an object format, not a string.
priceInfo: The data price symbol. Leran more bout PriceInfo Different
chainName
values correspond to different symbols.chainNamesymbolminimum price(1 means)ao
wAR(the Wrapped AR in AO)
0.000000000001 wAR
holesky
ETH
1 wei
ethereum
ETH
1 wei
permissionCheckers(optional): The addresses of the checkers. The default is an empty array. Learn more about IDataPermission
encryptionSchema(optional): Parameters used by the algorithm. The default is:
Returns
dataId
: A unique identifier for the data.
Example
Submit Task
Submit a task to the BAVO Network. You must pay both the data fee corresponding to the data provider
and the computing fee for the workers
.
Parameters
taskType: The type of the task. Just support
TaskType.DATA_SHARING
now. Leran more about TaskTypedataId: The
dataId
returned by theuploadData
interface.dataUserPk: The The user's public key generated by generateKey of Utils..
Returns
taskId
: The ID of the task.
Example
Note:
keyInfo is generated at Generate Key
Get Task Result
Get the result of the task.
Parameters
taskId: taskId returned by
submitTask
dataUserSk: The user's secret key generated by generateKey of Utils
timeout(optional): The timeout in milliseconds for getting the result, if you wait longer than this time a
timeout
exception will be thrown. Default 60000(60 seconds).
Returns
Uint8Array: The result of the task in plain text.
Example
Note
You need to make sure that the dataUserSk used and the dataUserPk used by the submitTask are part of the same key pair. keyInfo is generated at Generate Key
Get balance can withdraw
Get the balance of your wallet that can be withdrawn
Parameters
userAddress: Address to search
tokenSymbol: What token to search for. Now is
ETH
Returns
Balance: The token of the address. Leran more about Balance
Example
Withdraw token
Withdraw token.
Parameters
toAddress: Address to receive token
tokenSymbol: Which token to withdraw. Now is
ETH
amoun: The amount you want to withdraw needs to be less than
free
above.
Returns
Transaction: Transaction infomation.
Example
Type And Enum
KeyInfo
ChainName
StorageType
PriceInfo
TaskType
Balance
Solidity: IDataPermission
Developers should implement the IDataPermission contract to create custom checking logic. Data provider can assign a checker contract address
for data permission checking while uploading data. When task submitted by a data user, the BAVO Network Contract
requests permission from the assigned contract and then decides whether to continue or terminate the task based on the results returned.
IDataPermission.sol
An example for checking data whitelisting can be found at WhiteListDataPermission
Last updated