All objects are created in a similar fashion, and we will use StakingContract as an example
Line 1 Import the Object
Line 7 Create a new Object
Line 13 Login to access the Address & Network via Metamask
Line 20 Deploy the new Object
Line 23 Access Functions
Here you can create a Staking Contract with a given ERC20 Contract Address, login with metamask & connect with solidity methods available
import {
Application, DexStorage, ERC20Contract, StakingContract,
ERC20TokenLock, ERC721Collectibles, ERC721Standard
} from 'bepro-js';
/* 1.1 - Instantiate the App for Metamask functionality */
let app = new Application({ opt : { web3Connection : 'WEB3_LINK' } });
/* 1.2 - Instantiate Object Object or any other in a similar way (Staking, ERC20 etc..) */
let staking = new StakingContract({ contractAddress : null, /* Contract Address (optional) */
opt : { web3Connection : 'WEB3_LINK' } }):
/* 2 - Connect the App/Contract to the Metamask Web3 Injected wallet*/
await app.login();
await staking.login();
/* or instantiate with the provided web3Connection, for tests it was already done at object creation */
await app.start();
await staking.start();
/* 4 - Deploy Data */
await staking.deploy();
/* 5 - Access other Methods */
await staking.availableTokens();
What if the contract was deployed already?
If the Contract is already deployed the use case is very similar
Line 1 Import the Object
Line 7 Create a new Object
Line 13 Login to access the Address & Network via Metamask
Line 20 Assert the Object
Line 23 Access Functions
import {
Application, DexStorage, ERC20Contract, StakingContract,
ERC20TokenLock, ERC721Collectibles, ERC721Standard
} from 'bepro-js';
/* 1.1 - Instantiate the App for Metamask functionality */
let app = new Application({ opt : { web3Connection : 'WEB3_LINK' } });
/* 1.2 - Instantiate Object Object or any other in a similar way (Staking, ERC20 etc..) */
let staking = new StakingContract({ contractAddress : null, /* Contract Address (optional) */
opt : { web3Connection : 'WEB3_LINK' } }):
/* 2 - Connect the App/Contract to the Metamask Web3 Injected wallet*/
await app.login();
await staking.login();
/* or instantiate with the provided web3Connection, for tests it was already done at object creation */
await app.start();
await staking.start();
/* 4 - Deploy Data */
await staking.__assert();
/* 5 - Access other Methods */
await staking.availableTokens();