This question is about web3.js
I'm working on a very simple dapp to test out making a token. There's only two functions in my contract - one to mint coins and one to transfer them. I'm trying to make a fountain site where people can go get my token
The part that's confusing me is how I'm accessing the visitors account. This code snippet works - it'll let me grab their coinbase and use it as their default address.
var contractAddress = '0x791E39A210B49811459531A54790377540eFfcde';
var myCoin = eth.contract(contractABI).at(contractAddress);
var wallet = web3.eth.defaultAccount = web3.eth.coinbase;
var transaction = myCoin.mint(wallet, value)
But if I change it to not set the default address, i get an invalid address error. Below code does NOT work, despite me being able to log web3.eth.coinbase in the console no problem.
var contractAddress = '0x791E39A210B49811459531A54790377540eFfcde';
var myCoin = eth.contract(contractABI).at(contractAddress);
var wallet = web3.eth.coinbase;
var transaction = myCoin.mint(wallet, value)
Can anyone explain this implementation choice in web3.js? Why is my contract method dependent on defaultAccount in this way?