CryptoFly.us | CRYPTOCURRENCY BITCOIN SHIRTS CLOTHING APPAREL HATS

CRYPTO NEWS

Bitcoin’s Record-Breaking Week | This Week in Crypto – Oct 25, 2021

The post Bitcoin’s Record-Breaking Week | This Week in Crypto – Oct 25, 2021 appeared first on 99 Bitcoins.

 New all-time highs for Bitcoin, an 87% flash crash hits Binance.US, and would you …

Bitcoin’s Record-Breaking Week | This Week in Crypto – Oct 25, 2021 Read More »

Adding Wallet using web3.eth.accounts.wallet.add

On web3 0.20.1, I am using Infura to deploy a contract to Rinkeby. This probably requires me to add a wallet to web3.accounts to provide the gas needed. When I ran the following nodejs code, Web3 = require(‘web3’) var web3 = new Web3(new Web3.providers.HttpProvider(“https://rinkeby.infura.io/nyxynyx-api-key”)) var privateKey = ‘nyxynyx-private-key’ web3.eth.accounts.wallet.add(“0x” + privateKey); var contractCode = ‘60606-contract-code-here’;::Listen

On web3 0.20.1, I am using Infura to deploy a contract to Rinkeby. This probably requires me to add a wallet to web3.accounts to provide the gas needed.

When I ran the following nodejs code,

Web3 = require('web3') var web3 = new Web3(new Web3.providers.HttpProvider("https://rinkeby.infura.io/nyxynyx-api-key")) var privateKey = 'nyxynyx-private-key' web3.eth.accounts.wallet.add("0x" + privateKey);  var contractCode = '60606-contract-code-here'; var abi = [{"constant":false,"inputs":[{"name":"givenNumber","type":"uint8"}],"name":"setNumber","outputs":[],"type":"function"},{"constant":true,"inputs":[{"name":"givenNumber","type":"uint8"}],"name":"guessNumber","outputs":[{"name":"","type":"bool"}],"type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"from","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[],"name":"SetNumber","type":"event"}]; GuessNumber = web3.eth.contract(abi) var contractInstance = GuessNumber.new({from: web3.eth.accounts[0], gas: 200000, data: '0x' + contractCode}); 

the following error is encountered:

web3.eth.accounts.wallet.add("0x" + privateKey);                         ^  TypeError: Cannot read property 'add' of undefined 

Is this because web3.eth.accounts.wallet.add is a web3 v1.0 function? If it is, what is the equivalent code needed in v0.20.1?

Bitcoin’s Record-Breaking Week | This Week in Crypto – Oct 25, 2021

Shopping cart
There are no products in the cart!
Continue shopping
0