npm.io
1.1.4 • Published 8 years ago

decentraland-contracts

Licence
Apache-2.0
Version
1.1.4
Deps
1
Vulns
0
Weekly
0
Stars
23

Contracts

Decentraland contract interfaces to use from Javascript.

Use

The idea is to define here your own Contracts and work with them using eth to be imported elsewhere. A typical case is described below:

MANAToken.js

import { eth } from 'decentraland-commons'

import { abi } from './artifacts/MANAToken.json'

class MANAToken extends eth.Contract {
    static getDefaultAddress() {
      return '0xdeadbeef'
    }

    static getDefaultAbi() {
      return abi
    }

    async lockMana(sender, mana) {
     return await this.transaction(
          'lockMana', sender, mana, { gas: 120000 }
      )
    }
}

export default MANAToken

On the start of your app, maybe server.js

import { eth } from 'decentraland-commons'
import { MANAToken } from 'decentraland-contracts'

eth.connect({
  contracts: [
    MANAToken,
      // ...etc
  ]
})

const manaToken = eth.getContract('MANAToken')
manaToken.lockMana()

// or maybe

const manaToken = new ManaToken(/*address*/, /*abi*/)
eth.connect({
  contracts: [
      manaToken,
      // ...etc
  ]
})
manaToken.lockMana()

Contracts Addresses

Check here

Scripts

lint

Lint js files with eslint

docs

Builds an static page with the JSDoc documentation

test

Run tests using mocha and chai

Keywords