I already read the other topics with the same error, but that didn't solve my problem ...
When I try to communicate with test rpc between my web interface with my smart contract I have always error "vm exception while processing transaction : out of gas", whereas when I have only 4 input in my smart contract there are no problem.
I have already try to use that to initiate tesrpc (because only testrpc that didn't work):
testrpc --account="0x7231a774a538fce22a329729b03087de4cb4a1119494db1c10eae3bb491823e7, 1000000000000000000000"
testrpc -l 4500000000000
testrpc --gasPrice 20000
testrpc -g 1000000000000000
No matter what I use the gas use stays at 90000 and I think the error is related to that ... Thanks to the person who will help me !
Here is my contract :
pragma solidity ^0.4.18;
contract URP {
uint8 x1;
uint8 x2;
uint8 y1;
uint8 y2;
uint8 z1;
uint8 z2;
uint8 retailer;
uint8 value;
uint8 x;
uint8 y;
uint8 z;
uint8 shopper;
function SendCoin(uint8 _x1, uint8 _x2, uint8 _y1, uint8 _y2, uint8 _z1, uint8 _z2, uint8 _ret, uint8 _value, uint8 _x, uint8 _y, uint8 _z, uint8 _shop) public {
x1 = _x1;
x2 = _x2;
y1 = _y1;
y2 = _y2;
z1 = _z1;
z2 = _z2;
retailer = _retailer;
value = _value;
x = _x;
y = _y;
z =_z;
shopper = _shopper;
}
function getSendCoin() public constant returns (uint8, uint8, uint8, uint8, uint8, uint8, uint8, uint8, uint8, uint8, uint8, uint8) {
return (x1, x2, y1, y2, z1, z2, retailer, value, x, y, z, shopper);
}
}
And here's is my web interface :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" type="text/css" href="main.css">
<script src="./node_modules/web3/dist/web3.min.js"></script>
</head>
<body>
<div class="container">
<h1>SendCoin</h1>
<h2 id="sendcoin"></h2>
<label for="name" class="col-lg-2 control-label">x1</label>
<input id="x1" type="text">
<label for="name" class="col-lg-2 control-label">x2</label>
<input id="x2" type="text">
<label for="name" class="col-lg-2 control-label">y1</label>
<input id="y1" type="text">
<label for="name" class="col-lg-2 control-label">y2</label>
<input id="y2" type="text">
<label for="name" class="col-lg-2 control-label">z1</label>
<input id="z1" type="text">
<label for="name" class="col-lg-2 control-label">z2</label>
<input id="z2" type="text">
<label for="name" class="col-lg-2 control-label">retailer</label>
<input id="retailer" type="text">
<label for="name" class="col-lg-2 control-label">value</label>
<input id="value" type="text">
<label for="name" class="col-lg-2 control-label">x</label>
<input id="x" type="text">
<label for="name" class="col-lg-2 control-label">y</label>
<input id="y" type="text">
<label for="name" class="col-lg-2 control-label">z</label>
<input id="z" type="text">
<label for="name" class="col-lg-2 control-label">shopper</label>
<input id="shopper" type="text">
<button id="button">Push Data</button>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script>
if (typeof web3 !== 'undefined') {
web3 = new Web3(web3.currentProvider);
} else {
// set the provider you want from Web3.providers
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
}
web3.eth.defaultAccount = web3.eth.accounts[0];
var URPContract = web3.eth.contract([
{
"constant": true,
"inputs": [],
"name": "getSendCoin",
"outputs": [
{
"name": "",
"type": "uint8"
},
{
"name": "",
"type": "uint8"
},
{
"name": "",
"type": "uint8"
},
{
"name": "",
"type": "uint8"
},
{
"name": "",
"type": "uint8"
},
{
"name": "",
"type": "uint8"
},
{
"name": "",
"type": "uint8"
},
{
"name": "",
"type": "uint8"
},
{
"name": "",
"type": "uint8"
},
{
"name": "",
"type": "uint8"
},
{
"name": "",
"type": "uint8"
},
{
"name": "",
"type": "uint8"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_x1",
"type": "uint8"
},
{
"name": "_x2",
"type": "uint8"
},
{
"name": "_y1",
"type": "uint8"
},
{
"name": "_y2",
"type": "uint8"
},
{
"name": "_z1",
"type": "uint8"
},
{
"name": "_z2",
"type": "uint8"
},
{
"name": "_retailer",
"type": "uint8"
},
{
"name": "_value",
"type": "uint8"
},
{
"name": "_x",
"type": "uint8"
},
{
"name": "_y",
"type": "uint8"
},
{
"name": "_z",
"type": "uint8"
},
{
"name": "_shopper",
"type": "uint8"
}
],
"name": "SendCoin",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
}]);
web3.eth.accounts.forEach (account => {
balance = web3.eth.getBalance (account);
console.log (balance);
})
var URP = URPContract.at('0x538882ec49974f8815fee55ad7b40d6dd4b6b75d');
console.log(URP);
URP.getSendCoin(function(error, result){
if(!error)
{
$("#sendcoin").html(result[0]+' = x1 / x2 = '+result[1]+' / y1 = '+result[2]+' / y2 = '+result[3]+' / z1 = ' +result[4]+' / z2 = ' +result[5]+' / ret = '+result[6]+' / value = ' +result[7]+' / x = '+result[8]+' / y = '+result[9]+' / z = '+result[10]+' / shop = '+result[11] );
console.log(result);
}
else
console.error(error);
});
$("#button").click(function() {
URP.SendCoin($("#x1").val(), $("#x2").val(), $("#y1").val(), $("#y2").val(), $("#z1").val(), $("#z2").val(), $("#retailer").val(), $("#value").val(), $("#x").val(), $("#y").val(), $("#z").val(), $("#shopper").val());
});
</script>
</body>
</html>
Sorry my ABI is too long ...
function SendCoin
!!!testrpc --gasLimit=0xfffffffffff --account=0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef,1000000000000000000000000000000000000000
(and make sure that you replicate--account=...
with a unique key according to however many accounts that you use in your tests).