The Vault class binding for the Vauilt Oracle smart contract.
- Vault
-
new Vault(chainId: number, signer: Signer): Vault
-
- Defined in vault.ts:18
Constructor
-
The network chain ID Zap is associated with
-
The signer of transactions
chainId: number
- Defined in vault.ts:10
signer: Signer
- Defined in vault.ts:11
-
userBalance(userAddress: string): Promise<any>
-
- Defined in vault.ts:33
Retreives the balance of specified address.
-
The address to reference
The Promise of the balance
For this example, we are using chainId 4 and a Rinkeby provider node. The chainId and provider node can be replaced with the other available chainId's supported by Zap.
// Requires dotenv to allow the reading of environment variables
require("dotenv").config();
// Rinkeby chainId
const rinkebyChainId = 4;
// Requires the Vault class
const { Vault } = require('@zapprotocol/oracle-sdk');
// Requires the ethers.js library
const ethers = require("ethers");
// Infura Rinkeby URL
const testnetUrl = `https://rinkeby.infura.io/v3/${process.env.PROJECT_ID}`;
// Creates the instance for the Rinkeby testnet provider
const provider = new ethers.providers.JsonRpcProvider(
testnetUrl,
rinkebyChainId
);
// Creates the signer instance with the users private key and provider
const signer = new ethers.Wallet(process.env.PRIVATE_KEY, provider);
// Creates the Vault class instance on the Rinkeby testnet with the signer connected
const vault = new Vault(rinkebyChainId, signer);
const main = async () => {
let tx = await vault.userBalance(signer.getAddress());
};
main();