- %> brew install node (This will give you the npm command)
%> npm install truffle -g
%> npm install -g ganache-cli
Regarding Ganache for a nicer UI install the tool from the Ganache site
%> mkdir <project>
%> cd <project>
%> cp ~/.gitignore_truffle ./.gitignore
%> cp ~/.header_6thcolumn ./.header
%> git init
%> npm init
%> truffle init
%> npm install @openzeppelin/contracts
%> emacs truffle-config (change “solc:” stanza “version” to “0.8.0”)
%> git add .
%> git commit -am “initial commit”
(note: we are ignoring all the openzeppelin code under node_modules)
Now you are ready to start writing your smart contract!
Edit/create the appropriate migrations
file(s), compile and run:
%> truffle compile
%> truffle develop
The last command will launch a local faux Ethereum node and give you an interactive prompt to hold context for the locally deployed contract. At the prompt you can run "migrate" to build and (re)deploy your contract
(Use the --reset
flag with migrate
when you want to force a clean rebuild)
In the interactive environment you can run migrate
and then get a handle to the deployed contract and make calls against it
let instance myContract = await MyContract.deployed();
myContract.foo();
Remember that you can't let
more than once.
Notes: