SURI
Before running any script with the avn-api, let's set your AvN mnemonic or secret seed generated via the accounts page. There are two ways you can set this:
- Environment variable
- As a Parameter when Initialising
export AVN_SURI=<mnemonic OR secret seed>
Your secret URI (SURI) could either be a mnemonic (seed phrase) or the secret seed (private key) of your account.
For windows users, here's a guide on how to set your environment variable.
Examples
You can export your SURI, in your CLI, in the format of any of the examples below
export AVN_SURI='flag dynamic laptop often park illegal equip curve game blame junior warm'
OR
export AVN_SURI=0x5392ca60a61aea99fce14358798de93c1bc11c3696a905718738c71fae539c24
This does not return anything.
const AVN_API = require("avn-api");
const AVN_GATEWAY_URL = "https://gateway.testnet.aventus.io/";
const options = {
suri: "0x5392ca60a61aea99fce14358798de93c1bc11c3696a905718738c71fae539c24", // this is from the generated example account
};
const API = new AVN_API(AVN_GATEWAY_URL, options);
There are some other params that are accepted in options
, See here for the new split-fee functionality.
If no URL is passed the API will run in offline mode, exposing ONLY core utilities and can be initialised using the below:
const api = new AvnApi();
// OR
const api = new AvnApi(null, options);
It's important that you keep the mnemonic/seed secret safe and not expose it anywhere else. If this data is compromised, you could lose your funds.