-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapprove.js
More file actions
50 lines (42 loc) · 1.55 KB
/
Copy pathapprove.js
File metadata and controls
50 lines (42 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const {ethers, run, network} = require("hardhat")
async function main() {
/**
* # dev
* b2dev: yarn hardhat run scripts/examples/erc20/approve.js --network b2dev
* asdev: yarn hardhat run scripts/examples/erc20/approve.js --network asdev
* # pord
* b2: yarn hardhat run scripts/examples/erc20/approve.js --network b2
* as: yarn hardhat run scripts/examples/erc20/approve.js --network as
*/
const [owner] = await ethers.getSigners()
console.log("Owner Address: ", owner.address);
let tokenAddress;
if (network.name == 'b2dev') {
tokenAddress = "0xE6BF3CCAb0D6b461B281F04349aD73d839c25B06";
} else if (network.name == 'asdev') {
tokenAddress = "";
} else if (network.name == 'b2') {
tokenAddress = "";
} else if (network.name == 'as') {
tokenAddress = "";
}
console.log("Token Address: ", tokenAddress);
const MyERC20 = await ethers.getContractFactory('MyERC20');
const instance = MyERC20.attach(tokenAddress);
let approve = {
// to: process.env.B2_DEV_TOKEN_BRIDGE,
to: process.env.B2_DEV_CASHIER,
amount: '1000000000000000000000',
};
console.log("approve: ", approve);
const tx = await instance.approve(approve.to, approve.amount)
const txReceipt = await tx.wait(1);
console.log(`tx hash: ${txReceipt.hash}`)
console.log("allowance:", await instance.allowance(owner.address, approve.to));
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error)
process.exit(1)
})