1.0.9 • Published 6 years ago
web3-api v1.0.9
Introduction
This package was created in the course of the diploma thesis at the HTBLA Perg. It is designed to work with a Smart Contract not publicly avialable. Web3.js is used for the communication to the Smart Contract.
Installation
npm install web3-apiUsage with TypeScript
import * as web3 from "web3-api";
import { web3Api } from "web3-api";
let chain:web3Api = web3.init(fs.readFileSync("abi.json", 'utf8'), contractAddress, BlockchainUrl);The init() function creates a new web3Api object and returns it.
contractAddress is the unique Address of the Contract on the Blockchain and BlockchainUrl is the url on which the blockchain is available.
abi.json is the abi of the Smart Contract created in the course of the diploma thesis.
Once the Object is created, the functions can be used like this:
import * as web3 from "web3-api";
import { web3Api } from "web3-api";
let chain:web3Api = web3.init(fs.readFileSync("abi.json", 'utf8'), contractAddress, BlockchainUrl);
newEvent();
async function newEvent() {
let result = await chain.newEvent(UserAddress);
console.log(result);
return result;
}