Skip to content

Instantly share code, notes, and snippets.

@3esmit
Last active October 6, 2020 08:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 3esmit/53ea3eddf8963eda9cbb8e6fd241e5c1 to your computer and use it in GitHub Desktop.
Save 3esmit/53ea3eddf8963eda9cbb8e6fd241e5c1 to your computer and use it in GitHub Desktop.
## Using conventionalcommits for commit messages: https://www.conventionalcommits.org/en/v1.0.0/#specification
## creates scaffolding for an embark-project in the folder named <project-name>
# npx embark new <project-name>
## sets the license of project https://github.com/Ovyerus/license#readme https://spdx.org/licenses/
# npx license <SPDX Identifier>
# Envoirement Setup
## install node-js using nvm https://github.com/creationix/nvm
nvm install 10.17.0
## install go-ethereum
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install geth -y
## install ipfs or swarm using snap and initialize it
### ipfs
sudo snap install ipfs
ipfs init
### swarm
#TODO
# Project Setup
## move to a developments projects folder
cd ~/
mkdir my-projects
cd my-projects
## create a project as embark template
npx embark new my-governance-example
cd my-governance-example/
git init
## Setup basic files
npx license CC0-1.0
echo "# My Governance Example" > README.md
echo "# Change Log" > CHANGELOG.md
## Remove unneeded example test file
rm -rf test/contract_spec.js
git add .
git commit -m "feat: embark scaffolding"
## Disable Communication: Edit /config/communication.js, set enabled = 'false' to config
echo "diff --git a/config/communication.js b/config/communication.js
--- a/config/communication.js
+++ b/config/communication.js
@@ -1,7 +1,7 @@
module.exports = {
// default applies to all environments
default: {
- enabled: true,
+ enabled: false,
provider: \"whisper\", // Communication provider. Currently, Embark only supports whisper
available_providers: [\"whisper\"], // Array of available providers
client: \"geth\"
" | git apply
git add config/communication.js
git commit -m "feat(embark/config): disable communication"
## Disable Storage: Edit /config/storage.js, set enabled = 'false' to config
echo "diff --git a/config/storage.js b/config/storage.js
--- a/config/storage.js
+++ b/config/storage.js
@@ -1,7 +1,7 @@
module.exports = {
// default applies to all environments
default: {
- enabled: true,
+ enabled: false,
ipfs_bin: \"ipfs\",
available_providers: [\"ipfs\"],
upload: {
" | git apply
git add config/storage.js
git commit -m "feat(embark/config): disable storage"
## Disable Namesystem: Edit /config/namesystem.js, set enabled = 'false' to config
echo "diff --git a/config/namesystem.js b/config/namesystem.js
--- a/config/namesystem.js
+++ b/config/namesystem.js
@@ -1,7 +1,7 @@
module.exports = {
// default applies to all environments
default: {
- enabled: true,
+ enabled: false,
available_providers: [\"ens\"],
provider: \"ens\"
},
" | git apply
git add config/namesystem.js
git commit -m "feat(embark/config): disable namesystem"
# Create a Simple Governance
## Create smart contract inside ./contracts/
cp ../.history/files/contracts/MyGovernance.sol contracts/
git add contracts/MyGovernance.sol
git commit -m "feat(contracts): Add MyGovernance"
## Create tests inside ./test/
npm install --save-dev @openzeppelin/test-helpers
git add package.json package-lock.json
cp ../.history/files/test/mygovernance.spec.js test/
git add test/
git commit -m "feat(test): Add MyGovernance Tests"
## Run tests
npx embark test
## Install Solidity Libraries
### Sets solidity version 0.6.2 (to match with openzeppelin current solidity version)
npx json -I -f embark.json -e "this.versions.solc='0.6.2'"
git add embark.json
git commit -m "feat(embark/versions): Update to solc 0.6.2"
### Install OpenZeppelin.org Libraries
npm install openzeppelin-solidity
ln -s ../node_modules/openzeppelin-solidity/contracts/ ./contracts/openzeppelin-solidity
git add package.json package-lock.json contracts/openzeppelin-solidity
git commit -m "feat(contracts/libraries): Add openzeppelin"
### Disable Autodeploy: Edit /config/contracts.js, add default.strategy = 'explicit' to config
echo "diff --git a/config/contracts.js b/config/contracts.js
--- a/config/contracts.js
+++ b/config/contracts.js
@@ -24,7 +24,7 @@ module.exports = {
// when not specified
// - explicit will only attempt to deploy the contracts that are explicitly specified inside the
// contracts section.
- // strategy: 'implicit',
+ strategy: 'explicit',
// minimalContractSize, when set to true, tells Embark to generate contract files without the heavy bytecodes
// Using filteredFields lets you customize which field you want to filter out of the contract file (requires minimalContractSize: true)
" | git apply
git add config/contracts.js
git commit -m "feat(embark/config): disable autodeploy"
# Create frontend inside ./app/
## Enable AutoEnableDapps:
echo "diff --git a/config/contracts.js b/config/contracts.js
--- a/config/contracts.js
+++ b/config/contracts.js
@@ -14,7 +14,7 @@ module.exports = {
// Automatically call \`ethereum.enable\` if true.
// If false, the following code must run before sending any transaction: \`await EmbarkJS.enableEthereum();\`
// Default value is true.
- // dappAutoEnable: true,
+ dappAutoEnable: true,
gas: \"auto\",
" | git apply
git add config/contracts.js
git commit -m "feat(embark): enable autoenabledapps"
# development build
npx embark build
# testnet build
## enable testnet sync
echo "diff --git a/config/blockchain.js b/config/blockchain.js
--- a/config/blockchain.js
+++ b/config/blockchain.js
@@ -53,6 +53,8 @@ module.exports = {
testnet: {
networkType: \"testnet\", // Can be: testnet(ropsten), rinkeby, livenet or custom, in which case, it will use the specified networkId
syncMode: \"light\",
+ nodiscover: false, //false enables p2p connections (default true)
+ maxpeers: 25,//must be a number higher than zero (default 0)
accounts: [
{
nodeAccounts: true,
" | git apply
## testnet account backup
mkdir -p ~/keys/testnet && cp .embark/testnet/datadir/keystore/* ~/keys/testnet
## testnet read account address
geth --testnet --datadir=.embark/testnet/datadir --syncmode=light --gcmode=archive --password=config/testnet/password --ipcpath=/tmp/embark-5eaf3e7f/geth.ipc account list
## testnet run embark manually (workaround for newer geth)
geth --testnet --datadir=.embark/testnet/datadir --syncmode=light --gcmode=archive --password=/home/ricardo/Documents/GitHub/status-im/my-governance-example/config/testnet/password --ipcpath=/tmp/embark-5eaf3e7f/geth.ipc --port=30303 --rpc --rpcport=8545 --rpcaddr=localhost --rpccorsdomain=http://localhost:8000,http://embark --ws --wsport=8546 --wsaddr=localhost --wsorigins=http://localhost:8000,http://embark --maxpeers=25 --rpcapi=eth,web3,net,debug,personal --wsapi=eth,web3,net,debug,pubsub,personal --unlock=0x29467d0bcb400fa8cb0714e34af97a8a80c5ff47 --miner.gastarget=8000000 --allow-insecure-unlock
## open interactive shell with Geth
geth attach /tmp/embark-5eaf3e7f/geth.ipc
geth attach ws://localhost:8546
geth attach http://localhost:8545
## Get testnet ETH (Ropsten):
## https://faucet.dimensions.network/
## See your testnet account in a block explorer
## https://ropsten.etherscan.io/address/0x29467d0bcb400fa8cb0714e34af97a8a80c5ff47
## testnet account restore
mkdir -p .embark/testnet/datadir/keystore && cp ~/keys/testnet/* .embark/testnet/datadir/keystore/
# Publish project
## Upload to ipfs
ipfs add -r dist/
## Upload to swarm
swarm --defaultpath dist/index.html --recursive up dist/
## Setup ENS domain (go to https://app.ens.domains/)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment