... Other Objects
Simple Usage of the bepro-js
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
1
import {
2
Application, DexStorage, ERC20Contract, StakingContract,
3
ERC20TokenLock, ERC721Collectibles, ERC721Standard
4
} from 'bepro-js';
5
6
/* 1.1 - Instantiate the App for Metamask functionality */
7
let app = new Application({ opt : { web3Connection : 'WEB3_LINK' } });
8
9
/* 1.2 - Instantiate Object Object or any other in a similar way (Staking, ERC20 etc..) */
10
let staking = new StakingContract({ contractAddress : null, /* Contract Address (optional) */
11
opt : { web3Connection : 'WEB3_LINK' } }):
12
/* 2 - Connect the App/Contract to the Metamask Web3 Injected wallet*/
13
await app.login();
14
await staking.login();
15
/* or instantiate with the provided web3Connection, for tests it was already done at object creation */
16
await app.start();
17
await staking.start();
18
19
/* 4 - Deploy Data */
20
await staking.deploy();
21
22
/* 5 - Access other Methods */
23
await staking.availableTokens();
Copied!
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
1
import {
2
Application, DexStorage, ERC20Contract, StakingContract,
3
ERC20TokenLock, ERC721Collectibles, ERC721Standard
4
} from 'bepro-js';
5
6
/* 1.1 - Instantiate the App for Metamask functionality */
7
let app = new Application({ opt : { web3Connection : 'WEB3_LINK' } });
8
9
/* 1.2 - Instantiate Object Object or any other in a similar way (Staking, ERC20 etc..) */
10
let staking = new StakingContract({ contractAddress : null, /* Contract Address (optional) */
11
opt : { web3Connection : 'WEB3_LINK' } }):
12
/* 2 - Connect the App/Contract to the Metamask Web3 Injected wallet*/
13
await app.login();
14
await staking.login();
15
/* or instantiate with the provided web3Connection, for tests it was already done at object creation */
16
await app.start();
17
await staking.start();
18
19
/* 4 - Deploy Data */
20
await staking.__assert();
21
22
/* 5 - Access other Methods */
23
await staking.availableTokens();
24
Copied!
Last modified 4mo ago
Copy link