This can be used to hold an account inside Chrome for easier access to test wallet accounts - Use Rinkeby for testing
- Create social post with address
- Copy the post's link inside https://faucet.rinkeby.io/ to fund your test account
The programming language to be used is called Solidity. The documentation can be found at https://docs.soliditylang.org/en/v0.8.0/.
- Install NodeJS 14.15.0
- Create folder
- Go into folder
- npm init (creates package.json)
- npm install -g truffle
- truffle init
truffle create contract %contractName%
truffle compile
You can also run truffle develop and then run commands such as compile and migrate inside it.
Running migrate in develop migrates contracts to the blockchain.
truffle create migration %migrationName%.
Then you can add the following code to newly added file in the migrations directory.
const ContractName = artifacts.require('ContractName')
module.exports = function(deployer){
deployer.deploy(ContractName)
}
Add --reset to restart the migration
After running truffle init, one should find a file named truffle-config.json. Change the version under compilers > solc to 0.6.6.
compilers: {
solc: {
version: "0.6.6"
},
}
truffle develop uses Mocha for tests, whose documentation can be found at https://mochajs.org/.
truffle develop uses Chai for assertions, whose documentation can be found at https://www.chaijs.com/api/assert/ .
To deploy a smart contract once can use a public node.
- Go to infura.io
- Sign Up
- Create new project
- Get the endpoint from the project's settings under KEYS. Make sure Rinkeby is selected in the selectbox near ENDPOINTS
- Go into the directory of the newly created project(locally not on Infura)
- Run npm install @truffle/hdwallet-provider or npm install truffle-hdwallet-provider for older versions.
- Open truffle-config.js
- Get the mnemonic/seed from the MetaMask setting (Click top-right circle > settings > Security & Privacy > Reveal Seed Phrase). This should be like a long phrase with different words making no sense.
- Make sure the truffle-config.js file looks like this:
const metaMaskMnemonic = "seed obtained from metamask's settings";
const HDWalletProvider = require('@truffle/hdwallet-provider');
module.exports = {
networks: {
rinkeby: {
network_id: 4,
provider: new HDWalletProvider(metaMaskMnemonic, "endpoint obtained from infura's settings")
}
},
// Set default mocha options here, use special reporters etc.
mocha: {
// timeout: 100000
},
// Configure your compilers
compilers: {
solc: {
version: "0.6.6"
},
},
};
- Run truffle migrate --network rinkeby
The migrate command should return a contract address and this can be checked by going into https://rinkeby.etherscan.io/ and pasting the address there.
If you wish to test smart contracts quickly, one can also make use of an online IDE which can be found in this link, https://remix.ethereum.org/.