Loom support

A community member asked in Telegram if OpenZeppelin SDK can be used with Loom

There is an existing issue in OpenZeppelin SDK on this problem (which I have added to): https://github.com/OpenZeppelin/openzeppelin-sdk/issues/405

OpenZeppelin SDK uses JSON RPC methods web3_clientVersion and eth_getStorageAt which are not currently supported by Loom, created an issue to request support for these methods: https://github.com/loomnetwork/loom-js/issues/306

network.js

Include work around to add custom method for web3_clientVersion

const { readFileSync } = require('fs')
const LoomTruffleProvider = require('loom-truffle-provider')
 
const chainId = 'extdev-plasma-us1'
const writeUrl = 'http://extdev-plasma-us1.dappchains.com:80/rpc'
const readUrl = 'http://extdev-plasma-us1.dappchains.com:80/query'
 
// ./privateKey file contains a base64 encoded key generated by the command:
// loom genkey -a publicKey -k privateKey
const privateKey = readFileSync('./privateKey', 'utf-8')
 
const loomTruffleProvider = new LoomTruffleProvider(chainId, writeUrl, readUrl, privateKey)
 
// Create 10 extra accounts, useful for tests
loomTruffleProvider.createExtraAccounts(10)

const loomProvider = loomTruffleProvider.getProviderEngine()

loomProvider.addCustomMethod('web3_clientVersion', payload => {
  return 'Loom/v1.0.0/loom-js'
})

module.exports = {
  networks: {
    extdev_plasma_us1: {
      provider: function() {
        return loomTruffleProvider
      },
      networkId: '9545242630824'
    },
  },
};

Counter.sol

pragma solidity ^0.5.0;

contract Counter {
  uint256 public value;

  function increase() public {
    value++;
  }
}

Create contract

Fails on Method "eth_getStorageAt" not supported on this provider

$ npx oz create
Nothing to compile, all contracts are up to date.
Failed to initialize libusb.
? Pick a contract to instantiate Counter
? Pick a network extdev_plasma_us1
All contracts are up to date
? Do you want to call a function on the instance after creating it? No
✓ Instance created at 0xc95A4e26C3057a28933d5F1Fd06b9b223E31844C
Method "eth_getStorageAt" not supported on this provider

According to Loom:
May be supported in LoomProvider2 probably in next major hard fork so less then 4 weeks