bug: send gas when calling a function via API
This commit is contained in:
parent
b02cafe672
commit
d6f7c652f9
|
@ -113,9 +113,10 @@ class ContractsManager {
|
|||
const abi = contract.abiDefinition.find(definition => definition.name === req.body.method);
|
||||
const funcCall = (abi.constant === true || abi.stateMutability === 'view' || abi.stateMutability === 'pure') ? 'call' : 'send';
|
||||
|
||||
self.events.request("blockchain:contract:create", {abi: contract.abiDefinition, address: contract.deployedAddress}, (contractObj) => {
|
||||
self.events.request("blockchain:contract:create", {abi: contract.abiDefinition, address: contract.deployedAddress}, async (contractObj) => {
|
||||
try {
|
||||
contractObj.methods[req.body.method].apply(this, req.body.inputs)[funcCall]({from: account, gasPrice: req.body.gasPrice}, (error, result) => {
|
||||
const gas = await contractObj.methods[req.body.method].apply(this, req.body.inputs).estimateGas();
|
||||
contractObj.methods[req.body.method].apply(this, req.body.inputs)[funcCall]({from: account, gasPrice: req.body.gasPrice, gas}, (error, result) => {
|
||||
if (error) {
|
||||
return res.send({result: error.message});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue