Remix has a built in debugger that helps debug contracts
Solidity Gotcha's
Nested dynamic arrays cannot be used with the combination of both solidity and javascript
[
[1,2,3],
[4,5,6],
]
Solidity stores strings as dynamic arrays, ergo, something like:
const colors = ["red", "green", "blue"]
cannot be used. Pending solution in Grider course.
Get provider
const ganache = require("ganache-cli");
const Web3 = require("web3");
const web3 = new Web3(ganache.provider());
Get all accounts on network
web3.eth.getAccounts().then((fetchedAccounts) => {
console.log(fetchedAccounts);
});
Get value from contract
const message = await inbox.methods.message().call();
Modify a contract's data / Send a transaction to our contract
await inbox.methods.setMessage("bye").send({ from: accounts[0] });
Function that someone can send money along with 0.4.17
function enter() public payable {
players.push(msg.sender);
}
Require global variable
require(msg.value > 0.01 ether)
Send ether to address
players[index].transfer(this.balance)
address.transfer is the function