0

I can not find what the problem is, someone can help me

Contract

pragma solidity ^0.5.9;

contract certificarProceso {

    address public creador;
    address emisor;
    string informacion;
    string informacionHashArchivo;

    function escribirInformacion(string memory informacion1, string memory informacionHashArchivo1) public {
        informacion = informacion1;
        informacionHashArchivo = informacionHashArchivo1;
    }

    function getInformacion() public view returns (string memory) {
        return informacion;
    }

    function getInformacionArchivoHash() public view returns (string memory) {
        return informacionHashArchivo;
    }
}

Error

> personal.unlockAccount(eth.accounts[0])
Unlock account 0x2fef34e4d5a83a7bd78b2b09eb3619046eb1eaa1
Passphrase: 
true
> var abi= [{"constant":false,"inputs":[{"name":"informacion1","type":"string"},{"name":"informacionHashArchivo1","type":"string"}],"name":"escribirInformacion","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"creador","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getInformacion","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getInformacionArchivoHash","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"}]
undefined
> 
> var address ="0x93ba4ede5903c6656060c443255ed4ef569a5144"
undefined
> var contract=eth.contract(abi).at(address)
undefined
> contract.getInformacion()
Error: new BigNumber() not a base 16 number: 
    at L (bignumber.js:3:2876)
    at bignumber.js:3:8435
    at a (bignumber.js:3:389)
    at web3.js:1110:23
    at web3.js:1634:20
    at web3.js:826:16
    at map (<native code>)
    at web3.js:825:12
    at web3.js:4080:18

> 
  • Are you pointing the right contract address? Do you have synched your blockchain? – alberto Jul 7 '19 at 11:15
  • Hello Alberto, if my blockchain is synchronized and that is the correct address of the contract. I do not know where to look – Fernando Melossi Jul 8 '19 at 13:11
  • Have you deployed the contract? How did you get this address: 0x93ba4ede5903c6656060c443255ed4ef569a5144? – alberto Jul 8 '19 at 16:17
  • when I made the deploy I returned that contract address – Fernando Melossi Jul 9 '19 at 17:48
1

the problem is that the contract's address is undefined.

in the console remove the keyword var in the instantiation and keep just :

address ="0x93ba4ede5903c6656060c443255ed4ef569a5144"

same for abi ...

you can check afterwards if the value set by just typing the variable name in the console

exp

> address

0x93ba4ede5903c6656060c443255ed4ef569a5144
|improve this answer|||||
0

I thank you for your answer. I corrected what you indicated to me, but unfortunately it throws the same error. Then I tried another contract to rule out that I see a problem with that contract, but I also throw the same error

I am testing from the console because from my java application with web3j I get the following error when I want to read a variable of my contract

Error org.web3j.tx.exceptions.ContractCallException: Empty value (0x) returned from contract

And when I want to write a variable throws

org.web3j.protocol.exceptions.TransactionException: Transaction has failed with status: 0x0. Gas used: 4300000. (not-enough gas?)

thank you very much for your help

|improve this answer|||||
0

I made a new contract to carry out new tests, and I made the same mistake. I do not know where to look anymore. I would appreciate if someone helps me regards

contract

pragma solidity ^0.5.9;

contract certificarProcesoNuevo {
   struct  Informacion {
        string  informacion;
        string informacionHashArchivo;
    }
    mapping(string => Informacion) public historialInformacion;
    function escribirInformacion(string memory informacion,string memory informacionHashArchivo, string memory txn) public  {
        historialInformacion[txn].informacion = informacion;
        historialInformacion[txn].informacionHashArchivo = informacionHashArchivo;
    }
    function  getInformacion(string memory txn)  public view returns  (string memory) {
        return historialInformacion[txn].informacion;
    }
    function  getInformacionArchivoHash(string memory txn)  public view returns  (string memory) {
        return historialInformacion[txn].informacionHashArchivo;
    }

}

Console

> eth.defaultAccount ="0x2fef34e4d5a83a7bd78b2b09eb3619046eb1eaa1"

"0x2fef34e4d5a83a7bd78b2b09eb3619046eb1eaa1"

> personal.unlockAccount(eth.accounts[0])

Unlock account 0x2fef34e4d5a83a7bd78b2b09eb3619046eb1eaa1

Passphrase:

true

> abi=[{"constant":false,"inputs":[{"name":"informacion","type":"string"},{"name":"informacionHashArchivo","type":"string"},{"name":"txn","type":"string"}],"name":"escribirInformacion","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"txn","type":"string"}],"name":"getInformacionArchivoHash","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"txn","type":"string"}],"name":"getInformacion","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"string"}],"name":"historialInformacion","outputs":[{"name":"informacion","type":"string"},{"name":"informacionHashArchivo","type":"string"}],"payable":false,"stateMutability":"view","type":"function"}]

[{

    constant: false,

    inputs: [{

        name: "informacion",

        type: "string"

    }, {

        name: "informacionHashArchivo",

        type: "string"

    }, {

        name: "txn",

        type: "string"

    }],

    name: "escribirInformacion",

    outputs: [],

    payable: false,

    stateMutability: "nonpayable",

    type: "function"

}, {

    constant: true,

    inputs: [{

        name: "txn",

        type: "string"

    }],

    name: "getInformacionArchivoHash",

    outputs: [{

        name: "",

        type: "string"

    }],

    payable: false,

    stateMutability: "view",

    type: "function"

}, {

    constant: true,

    inputs: [{

        name: "txn",

        type: "string"

    }],

    name: "getInformacion",

    outputs: [{

        name: "",

        type: "string"

    }],

    payable: false,

    stateMutability: "view",

    type: "function"

}, {

    constant: true,

    inputs: [{

        name: "",

        type: "string"

    }],

    name: "historialInformacion",

    outputs: [{

        name: "informacion",

        type: "string"

    }, {

        name: "informacionHashArchivo",

        type: "string"

    }],

    payable: false,

    stateMutability: "view",

    type: "function"

}]

>

>

> address ="0x1ea642921b3c13f724fca3e16a4af58b975269ee"

"0x1ea642921b3c13f724fca3e16a4af58b975269ee"

> contract=eth.contract(abi).at(address)

{

  abi: [{

      constant: false,

      inputs: [{...}, {...}, {...}],

      name: "escribirInformacion",

      outputs: [],

      payable: false,

      stateMutability: "nonpayable",

      type: "function"

  }, {

      constant: true,

      inputs: [{...}],

      name: "getInformacionArchivoHash",

      outputs: [{...}],

      payable: false,

      stateMutability: "view",

      type: "function"

  }, {

      constant: true,

      inputs: [{...}],

      name: "getInformacion",

      outputs: [{...}],

      payable: false,

      stateMutability: "view",

      type: "function"

  }, {

      constant: true,

      inputs: [{...}],

      name: "historialInformacion",

      outputs: [{...}, {...}],

      payable: false,

      stateMutability: "view",

      type: "function"

  }],

  address: "0x1ea642921b3c13f724fca3e16a4af58b975269ee",

  transactionHash: null,

  allEvents: function(),

  escribirInformacion: function(),

  getInformacion: function(),

  getInformacionArchivoHash: function(),

  historialInformacion: function()

}

> contract.escribirInformacion("hola","hola1","0x7d0")

"0x2c0d6178c28de8f49680f73b6c2ea3317eb7ea166aa08397b3f2d376bc9f8ac8"

> contract.getInformacionArchivoHash("0x7d0")

Error: new BigNumber() not a base 16 number:

    at L (bignumber.js:3:2876)

    at bignumber.js:3:8435

    at a (bignumber.js:3:389)

    at web3.js:1110:23

    at web3.js:1634:20

    at web3.js:826:16

    at map (<native code>)

    at web3.js:825:12

    at web3.js:4080:18



> eth.getTransaction('0x2c0d6178c28de8f49680f73b6c2ea3317eb7ea166aa08397b3f2d376bc9f8ac8')

{

  blockHash: "0x954bb63e7f8f8df14ed228ef955e0e37d99913c9054c69f9aa4f365b11273f49",

  blockNumber: 4933937,

  from: "0x2fef34e4d5a83a7bd78b2b09eb3619046eb1eaa1",

  gas: 90000,

  gasPrice: 22000000000,

  hash: "0x2c0d6178c28de8f49680f73b6c2ea3317eb7ea166aa08397b3f2d376bc9f8ac8",

  input: "0x149a7cca000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000004686f6c61000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005686f6c613100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000053078376430000000000000000000000000000000000000000000000000000000",

  nonce: 79,

  r: "0xa6e82a347f8ccf888ba77d28a36f81626e3f495a11b7054c56bfa8d9084045c2",

  s: "0x66be6af999abeef7e7f457c875f2edc0508ffb78f28300f92efaed2b2b348ba5",

  to: "0x1ea642921b3c13f724fca3e16a4af58b975269ee",

  transactionIndex: 0,

  v: "0x17f44054",

  value: 0

}
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.