@sovryn-zero/lib-ethers
Version:
Sovryn Zero SDK Ethers-based implementation
55 lines (34 loc) • 1.82 kB
Markdown
[](/LICENSE)
[](https://github.com/DistributedCollective/zero/stargazers)
[](/README.md)
[](https://www.npmjs.com/package/ethers)-based library for reading Zero protocol state and sending transactions.
```
npm install @sovryn-zero/lib-base @sovryn-zero/lib-ethers ethers@^5.0.0
```
To install early access releases (pre-releases) - use a specific version to install:
```
npm install @sovryn-zero/lib-ethers@1.0.0-early.access.0
```
The actual early access release version is [here](https://github.com/DistributedCollective/zero/blob/sdk-publish/packages/lib-ethers/package.json#L3).
### Connecting to an Ethereum node and sending a transaction:
```javascript
const { Wallet, providers } = require("ethers");
const { EthersLiquity } = require("@sovryn-zero/lib-ethers");
async function example() {
const provider = new providers.JsonRpcProvider("http://localhost:8545");
const wallet = new Wallet(process.env.PRIVATE_KEY).connect(provider);
const zero = await EthersLiquity.connect(wallet);
const { newTrove } = await zero.openTrove({
depositCollateral: 5, // ETH
borrowZUSD: 2000
});
console.log(`Successfully opened a Zero Trove (${newTrove})!`);
}
```
See [packages/examples](https://github.com/DistributedCollective/zero/tree/master/packages/examples) in the repo.
[](https://github.com/DistributedCollective/zero/blob/master/docs/sdk/lib-ethers.md).