Skip to content
This repository has been archived by the owner on Jan 1, 2020. It is now read-only.

Finhaven/Cryptomon

Repository files navigation

Cryptomon ⛰🌪🔥🌊

CircleCI Maintainability

Finhaven tokens and other Ethereum smart contracts

We are using the Truffle Framework

Install

> npm install

Test

> npm run test

Compile

However, if you change smart contracts, you will need to recompile them. You can do this with

> npm run truffle:compile

Local REPL

> ganache-cli
const Web3 = require('web3');

const provider = new Web3.providers.HttpProvider("http://localhost:8545");
const web3 = new Web3(provider);

const CritterFile = fs.readFileSync('./build/contracts/Critter.json');
const {abi, bytecode} = JSON.parse(CritterFile);

let accounts;
web3.eth.getAccounts().then(accs => {
  accounts = accs
});

// Prove that it worked
accounts; 

let hydroge;
new web3.eth.Contract(abi).deploy({
    data: bytecode,
    arguments: ["Hydroge", 1]
  }).send({
    from: accounts[0],
    gas: "1000000"
  }).then(deployed => {
    hydroge = deployed;
  });

// Prove that it worked
hydroge; 

// hydroge.methods.name().call({ from: accounts[0] }).then(res => console.log(JSON.stringify(res)));

const command = (funName, args = []) => {
  hydroge.methods[funName](...args).call({
    from: accounts[0]
  }).then(res => console.log(JSON.stringify(res)));
};

command('name');
// => "Hydroge"

command('selfHeal', [2]);
// => {}