Search code examples
javascriptblockchainethereumweb3jseris-blockchain

Method not found: erisdb.call


Hey i'm trying to use the eris-contracts package to interact with smart contracts on the monax platform.

The contracts i had used to work fine in the eris release of the blockchain, but when i updated to the new monax version, i'm getting this weird error:

Eris DB error: Call of method "call" with parameters { from: '424FF9990BD1AD02CB7294914986E27343E702EB', address: '723388A1EA103460561FA1758CE4BBCD8322F9F6', data: 'a5f3c23b00000000000000000000000000000000000000000000000000000000000000220000000000000000000000000000000000000000000000000000000000000016' } responded with "Method not found: erisdb.call".

I tried making a really simple contract (with an add method) and tried to invoke it. But whenever i try to call any method on the contract:

sumContract.add(34, 22, addCallback);

function addCallback(error, sum){
  console.log(sum.toString()); // Would print: 56
}

i got back the above error.

I've been following the Smart Contracts JS SDK on the site, just to be sure that there are not syntax changes when things upgraded to monax.

It doesn't look like anything wrong with the blockchain installation itself, since running the epm.yaml does give the desired result.

jobs:

- name: deployAddContract
  job:
    deploy:
      contract: AddContract.sol

- name: queryStorage
  job:
    query-contract:
      destination: $deployAddContract
      data: add 5 6

Here's the contract initiation code:

var fs = require('fs');
var erisC = require('eris-contracts');

var erisdbURL = "http://localhost:1337/rpc";

var contractData = require('./jobs_output.json');
var contractAddress = contractData["deployAddContract"];
var contractAbi = JSON.parse(fs.readFileSync("./abi/" + contractAddress));

var contractsManager = erisC.newContractManagerDev(erisdbURL, {
    "address": "424FF9990BD1AD02CB7294914986E27343E702EB",
    "pubKey": "97AE5615D4C6CB3C5F949B1EFC3F6B841EBF4BE4069A942F02D9CF654614D3D6",
    "privKey": "FD5C9BAA698FF3B13B94B2F9CCCB74DDD62257D787839A57B70EDD32E59B467497AE5615D4C6CB3C5F949B1EFC3F6B841EBF4BE4069A942F02D9CF654614D3D6"
});

var sumContract = contractsManager.newContractFactory(contractAbi).at(contractAddress);

Here are the versions of the different pieces:

  • eris-contracts : 0.15.12
  • monax : 0.16.0
  • solidity : 0.40.0
  • node : 8.1.0
  • npm : 5.0.3

Solution

  • Okay so turns out eris-contracts does not apply to newer monax versions (i think).

    There's a new npm library : @monax/legacy-contracts that's going to do the trick. I don't exactly get why the eris-contracts is failing, but changing the dependency fixes things.