I would like to set a default account for my web3 operations with web3js but it does not work.
I'm using web3@1.0.0-beta.29
and here is my code.
const Web3 = require('web3')
const Token = require('./Token.json')
const web3 = new Web3(new Web3.providers.HttpProvider())//provider.web3
web3.eth.defaultAccount = '0x4615ff6690a3bb23bd85051c5c69abba4092bbb4'
const tkn = new web3.eth.Contract(Token.abi, '0xba9d4199fab4f26efe3551d490e3821486f135ba')
tkn.methods.transfer('0x4615ff6690a3bb23bd85051c5c69abba4092bbb4', 1e9)
.send()
.then(console.log)
.catch(console.log)
the output of this is
Error: No "from" address specified in neither the given options, nor the default options.
the documentation says that this should not happen
Best Answer
I ran into the same problem. I had to explicitly specify the address on the
send
function call, like this: