Skip to content
Nayms smart contracts
Solidity JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
contracts
maker-otc @ b5b2a08
migrations
scripts
test
.babelrc
.deployment-sample.js
.gitattributes
.gitignore
.gitmodules
.solcover.js
.solhint.json
.solhintignore
LICENSE.md
README.md
constants.js
deployedAddresses.json
index.js
package.json
truffle-config.js
yarn.lock

README.md

CircleCI Coverage Status

Nayms Smart contracts.

Usage

Install the package:

npm install @nayms/contracts

Then, using truffle-contract you can import and use the deployer:

const promisify = require('es6-promisify')
const TruffleContract = require('truffle-contract')
const Web3 = require('web3')
const { FUCDeployer } = require('@nayms/contracts')

async init = () => {
  const web3 = new Web3(/* ... */)

  const contract = TruffleContract(FUCDeployer)
  contract.setProvider(web3.currentProvider)

  const deployer = await contract.deployed()

  // deploy a new FUC
  await deployer.deploy(/*...*/)

  const events = await promisify(deployer.contract.getPastEvents, deployer.contract)('NewFUC')

  const { returnValues: { deployedAddress } } = events.pop()

  console.log(`New contract deployed at: ${deployedAddress}`)
}

Using ethereum-events-logs you can parse logs for events:

// import the parser
const { parseLog } = require('ethereum-event-logs')
const { events: { NewFUC } } = require('@nayms/contracts')

const receipt = /* execute tx on chain and wait for receipt */

// we can parse all events in the contract by passing through the ABI:
const events = parseLog(receipt.logs, [ NewFUC ])

console.log(events)
/*
  [
    {
      name: 'NewFUC',
      address: '0x...',
      blockNumber: 123...,
      blockHash: '0x...',
      transactionHash: '0x...',
      ...
    },
  ]
*/

## Development

Note: Requires Node 12+

Install dependencies:

yarn

Initialize git submodules (for maker-otc trading engine):

git submodule init
git submodule update

First, run the dev network in a separate terminal:

yarn devnet

Now deploy the contracts to it:

yarn deploy:local

Now you can run the tests:

yarn test
You can’t perform that action at this time.