Skip to main content

Configuring

Introduction

As we previously saw, in order to get a hold on a precious session, one would need to call one of the 2 available static-factory methods:

  • ApiSession.default(params?, path?)
  • ApiSession.buildFrom(StratoContext)

Both of them return a Promise which, when resolved, give back the ApiSession instance to play with. In fact, ApiSession.buildFrom(StratoContext) is wrapped by it's default sibling which, we could argue, will most likely probability end up to being used the most.

This section describes the arguments of ApiSession.default and how they can be used to obtain a session to operate on.

The default session can be procured in one of the 4 following ways:

  • ApiSession.default() - run most often with no arguments at all, in which case it will try to load the parameters from the environment file present at HEDERAS_ENV_PATH environment-variable path or, if not specified, default loading the .env from repo-root. This is basically equivalent to calling ApiSession.default({}, path = process.env.HEDERAS_ENV_PATH || '.env')
  • ApiSession.default(path) - parse params present at path env-file location. This ends up running ApiSession.default({}, path)
  • ApiSession.default(params) - build the desired context unpacking a runtime representation of a json object. This is equivalent to running ApiSession.default(params, path = process.env.HEDERAS_ENV_PATH || '.env')
  • ApiSession.default(params, path) - creates a session-execution context (StratoContext) by doing a parameter resolution over the provided arguments

Following is a table detailing all the object-parameters along with their environmental variables counterparts which can be used to bootstrap a Venin session.

Big table o' parameters

Environment VariableParameter PropertyRequiredTypeDefaultDescription
HEDERAS_WALLET_CONTROLLER_DEFAULT_PRIVATE_KEYwallet.controller.default.operatorKey6--The private-key used by the operators when switching accounts on a Sdk wallet using a DefaultPrivateKeyWalletController
HEDERAS_WALLET_CONTROLLERwallet.controller.type-Hedera, DefaultPrivateKeyHederaThe type of wallet-controller deployed. It's basically laying out the foundation of wallet-integration since a controller can propagate either an account-change or a network change.
HEDERAS_WALLET_TYPEwallet.typeNoSdkSdkThe wallet type used for the underlying session interactions (see wallets guide)
HEDERAS_WALLET_WINDOW_PROPERTY_NAMEwallet.window.propNameNostringhederaWhen bundling, the property location of the HIP-338 compliant wallet definition available on the global, window object
HEDERAS_CONTRACTS_INCLUDED_PREFIXES-No5contractsThe places to search for imported contract paths from within a solidity code. The contract's parent folder is the first one being searched, followed by the project's node_modules and then, if nothing matches, the rest of the included prefixes are looked at in the order in which they are defined
HEDERAS_CONTRACTS_RELATIVE_PATH-NopathcontractsThe name of the folder relative to the project root directory where all the solidity contracts are expected to reside. This is used when Venin is doing the contract compiling of a given relative-pathed contract
HEDERAS_DEFAULT_CONTRACT_CREATION_GASsession.defaults.contractCreationGasNonumber150000The default amount spent for creating a contract on the network
HEDERAS_DEFAULT_CONTRACT_REQUESTS_RETURN_ONLY_RECEIPTSsession.defaults.onlyReceiptsFromContractRequestsNobooleantruetrue to return only receipts for all state-mutating/transactions live-contract call, false otherwise. Contract queries (non-mutating calls) are not affected by this param. If desired, can be tweaked by the onlyReceipt contract-call meta-argument at an individual level.
HEDERAS_DEFAULT_CONTRACT_TRANSACTION_GASsession.defaults.contractTransactionGasNonumber169000The default amount given when executing a contract transaction
HEDERAS_DEFAULT_EMIT_CONSTRUCTOR_LOGSsession.defaults.emitConstructorLogsNobooleantruetrue to emit the constructor logs at contract-creation time, false otherwise
HEDERAS_DEFAULT_EMIT_LIVE_CONTRACT_RECEIPTSsession.defaults.emitLiveContractReceiptsNobooleanfalsetrue to ask for and emit the receipts originating from live-contract calls, false otherwise
HEDERAS_DEFAULT_PAYMENT_FOR_CONTRACT_QUERYsession.defaults.paymentForContractQueryNonumber20000000The default amount of tinybars payed for doing a contract query call. If not specified, relies on an upper limit given by the Hedera's SDK which is, currently, 1ℏ ( might change in the future, see #11 )
HEDERAS_NETWORKnetwork.nameYespreviewnet, testnet, mainnet, customnet-The network profile to use
HEDERAS_NODESnetwork.nodes43-A condensed address-book representation of the network nodes (see3)
HEDERAS_OPERATOR_IDwallet.hedera.operatorId2--The account-id of the operator running a Sdk wallet
HEDERAS_OPERATOR_KEYwallet.hedera.operatorKey2--The operator private-key of the operator running a Sdk wallet
HEDERAS_LOGGER_LEVELlogger.levelNoerror, warn, info, verbose, debug, sillyinfoThe logger sensitivity 1
HEDERAS_LOGGER_ENABLEDlogger.enabledNobooleanfalsetrue to enable the logger, false otherwise
HEDERAS_ENV_PATH-Nopath.envThe path of the .env like file used to source the config parameters from

Parameters resolution

The default context parameters are being resolved in the following order:

  • First, the runtime object-argument is checked and if a config property is present there, that's the one being used otherwise
  • If process.env (nodejs-case) contains that equivalent environment variable, that is the one which will be used else
  • If the HEDERAS_ENV_PATH environment file path has been supplied, exists and contains the same keys expected in process.env, it will be used else
  • If a .env file exists and it contains the same key expected in process.env, that's one is being used.

If none of the above conditions are true and the parameter is not mandatory, the default value is loaded or an error eventually propagates.


  1. see https://github.com/winstonjs/winston#logging
  2. required if HEDERAS_WALLET_TYPE/wallet.type is Sdk (the default)
  3. a comma separated string of node-network addresses having the following format : <ip>:<port>#<account_id> eg 127.0.0.2:52111#3 to make an address-book of one node located at 127.0.0.1, port 52111 having account-id 0.0.3
  4. required if HEDERAS_NETWORK/network.name is customnet
  5. a comma separated list of relative folder paths to look at when importing a relative solidity contract-file from within one of the contracts that we wish to compile
  6. required if HEDERAS_WALLET_CONTROLLER_TYPE is DefaultPrivateKey