forked from LaGuerrePiece/p2pBridge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tx.js
48 lines (45 loc) · 1.28 KB
/
tx.js
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
const HDWalletProvider = require("@truffle/hdwallet-provider");
const fs = require("fs");
const Web3 = require("web3");
const BigNumber = require("bignumber.js");
const mnemonic = fs.readFileSync("mnemonic.txt").toString().trim();
let bridgeAbi = JSON.parse(
fs.readFileSync("build/contracts/BridgeDex.json").toString().trim()
)["abi"];
let erc20Abi = JSON.parse(
fs.readFileSync("build/contracts/BridgeDex.json").toString().trim()
)["abi"];
const web3a = new Web3(
new HDWalletProvider({
mnemonic: mnemonic,
providerOrUrl: `https://rpc.ankr.com/polygon_mumbai`,
chainId: 77,
})
);
const web3b = new Web3(
new HDWalletProvider({
mnemonic: mnemonic,
providerOrUrl: `https://rpc.ankr.com/polygon_mumbai`,
chainId: 338,
})
);
const bridgeContract = new web3.eth.Contract(
gameAbi,
"0x1a152ac0E31A8b9784AF8cC6C65Bf1C0aD3a33bf"
);
web3.eth.getAccounts().then((accounts) => {
console.log(accounts);
gameContract.methods
.addBalances(7, new BigNumber("2000e18").toFixed(), 2)
//.addDefense(0, 2, 40)
.send({ from: accounts[0] })
.on("sent", (obj) => {
console.log(obj, " was sent");
})
.on("transactionHash", (string) => {
console.log("hash ", string);
})
.on("receipt", (receipt) => {
console.log(receipt);
});
});