@saturn-chain/web3-functions
v1.0.14
Published
Implements the functions needed to interface the smart contract functions and events with the web3js API.
Downloads
15
Readme
web3-function: implementation of EthProviderInterface
Implements the functions needed to interface the smart contract functions and events with the web3js API.
One should wonder why using web3-eth-contract
library encapsulated in smart contract and use web3 encapsulated library in this lib !
First, it is because it was needed to have smart contract code and usage independent of how to reach the blockchain (hexagonal architecture), and Second, because the sending of a transaction to the blockchain requires signature, sometime external, balance control, possible retry, waiting transaction completion ...
Also, this implementation is for the moment relatively trivial, and is firstly built to test smart contracts with a mocha
framework using ganache-core
as web3 provider.
Usage:
npm i --save @saturn-chain/web3-function
Includes typescript types declaration
Documentation
import { Web3FunctionProvider } from "web3-functions";
import Ganache from "ganache-core";
const intf = new Web3FunctionProvider(
// a web3 provider instance or a we3 instance
Ganache.provider() as any,
// an async function receiving a list of available address to select the desired one
list=>Promise.resolve(list[0])
);