Git Product home page Git Product logo

blox-staking-contracts's Introduction



Discord

Dependencies

brew install node@12
npm install -g solc 
npm install -g truffle 
npm install -g truffle-flattener
npm install -g remixd

Download Genache latests UI

Compile

First, clone the repo via git and install dependencies:

git clone https://github.com/bloxapp/blox-staking-contracts
cd blox-staking-contracts
npm install
truffle compile

Local test network

See Genache quickstart for more info

1. Infura account

  1. Create an infura account
  2. Create a new Ethereum project with API keys for the Mainnet.
  3. Go to settings page and copy wss endpoint in KEYS section.

2. Genache UI

  1. Download and run Genache UI
  2. Once the app is running, there will be two options in the fist screen: QUICKSTART and NEW WORKSPACE. Chose the new workspace one.
  3. Go to Server tab, and enable Chain forking. After that there will be two more inputs related to fork.
  4. Paste infura URL copied in p.3 above into ENTER CUSTOM URL input.
  5. Go to https://etherscan.io/blocks, copy the latest block number, and paste that into BLOCK NUMBER input.
  6. Go to SERVER tab and set port 8545.
  • Not supported for node@14

Enable CONTRACTS tab in Ganache UI

  • Go to CONTRACTS tab in Genache UI.
  • Click ADD PROJECT button and chose truffle-config.js in the root of the project.
  • Reload the workspace.

Now you can see all your contracts under this tab.

Deployment (currently on local testnet)

truffle migrate development

Interacting with the contract (cli)

truffle console
truffle(development)> let instance = await BloxStaking.deployed()
truffle(development)> instance.getTotalStaked()
BN { negative: 0, words: [ 0, <1 empty item> ], length: 1, red: null }

Debug contract

We can debug our contracts using remix + remixd. Instructions from: https://medium.com/authereum/debugging-solidity-with-a-gui-remix-and-ganache-c6c16488fcfd

NOTE: Run the remox-ide locally using docker. See instruction there https://github.com/ethereum/remix-ide#docker.

(we can use Genache UI instead of the CLI)

We should use the truffle deployment and then copy paste the addresses to Remix.

$ docker pull remixproject/remix-ide:latest
$ docker run --network="host" -p 80:80 remixproject/remix-ide:latest

Produce a first transaction

This is the description how to produce a transaction to the BloxStaking smart contract.

Once the remix-ide is started and REMIXD plugin is enabled, contracts are ready to be deployed.

Deploy smart contract first:

  • Find and open BloxStaking smart contract in the file explorers tab of remix-ide page.
  • Compile this smart contract to make sure it's valid.
  • Open Deploy & run transactions tab in remix-ide.
  • Chose Web3 Provider option in the ENVIRONMENT input.
  • Chose account with enough ETH amount on its balance.
  • Chose BloxStaking contract in the CONTRACT tab.
  • Open BloxStaking contract in CONTRACTS tab of Ganache UI.
  • Copy CDT, Exchange, and Deposit Contract values from Ganache UI to remix-ide fields under the deployment button.
  • Click transact button.

Make validator deposit transaction to the deployed contract:

  • Open Deploy & run transactions tab in remix-ide.
  • Under Deployed Contracts section chose the deployed BloxStaking smart contract.
  • Open validatorDeposit section in the list of contract's actions.
  • Fill the required fields to make a deposit: pubkey, withdrawal_credentials, signature, and deposit_data_root.
  • Click transact button.

Connect MetaMask plugin to local Ganache network

This requires the installed MetaMask plugin in a browser.

  • Open MetaMask plugin
  • Open the networks list and chose Custom RPC option.
  • Specify network name, e.g. My Local Network.
  • Specify the Ganache network RPC address, it should be http://127.0.0.1:8545.
  • Open ACCOUNTS tab in Ganache UI.
  • Chose an account that should be liked to MetaMask wallet, and click on "key" icon.
  • Copy private key of the selected account.
  • Go to MetaMask plugin and open the import account screen.
  • Paste the copied private key in the MetaMask input.
  • Save the account.

Smart contracts

IMPORTANT: Anyone who develops upgradable smart contracts must read all articles from there https://docs.openzeppelin.com/upgrades-plugins/1.x/

Smart contracts is the entity in blockchain similar with wallets. From the developer perspective, it looks like a class in a programming. It may have functions, variables, etc.

Smart contract doesn't have a private key, but can receive payments, and can handle that.

Smart contract balance stores in the blockchain, and that info can be stored in local variables of a smart contract as well, like with classes in Java.

Smart contracts should be upgradable. More information can be found there:

License

GPL © Blox Live



blox-staking-contracts's People

Contributors

alonmuroch avatar lior-blox avatar roman-blox avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.