Oramp SDK
This library streamlines the integration process with the Oramp protocol by abstracting its underlying complexity, making it simpler to use.
Table of contents
Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
Installation
To install, run:
$ npm install @oramp/sdk
Usage
To initialize the oramp client:
import {
ENVIRONMENTS, TESTNET_NETWORKS,
SUPPORTED_PROVIDERS, OrampError,
OrampClient, Web3Provider, Web3Wallet
} from '@oramp/sdk'
(async () => {
const RPC_URL = '<RPC_URL_HERE>'
const PRV_KEY = '<PRIVATE_KEY_HERE>'
// Initialize the provider
const provider = new Web3Provider({
environment: ENVIRONMENTS.TESTNET,
network: TESTNET_NETWORKS.MUMBAI,
provider: SUPPORTED_PROVIDERS.JSON_RPC,
rpcUrl: RPC_URL,
})
await provider.init()
// Initialize the wallet
const wallet = new Web3Wallet(
provider,
PRV_KEY
)
await wallet.init()
// Initialize the Oramp client
const oramp = new OrampClient({
provider,
})
// oramp.<SMART_CONTRACT>.<FUNCTION>(<PARAMS>)
try {
// Data call
console.log(await oramp.Dao().getStableCoinAddress())
// Action call
// Below should throw an error if no sufficent permissions
console.log(
await oramp.Dao().approveSubNetwork(
0,
wallet.getWallet()
)
)
} catch (e:unknown) {
if (e instanceof OrampError) {
console.log(e)
}
}
})()