4

I learned from this answer that truffle configures gasPrice in truffle.js, defaulting to 100000000000.

I'd like to use gasPrice in a test, without hardcoding the raw number. Is there any way to retrieve truffle's configuration variables?

  • 2
    A kludgy way of retrieving gasPrice is MyContract.class_defaults.gasPrice where MyContract has been imported with artifacts.require('MyContract'). – Keith Sep 1 '17 at 17:49
0
async () => {
  let result = await MyContract.function(payload);                  
  var gasPrice = web3.eth.getTransaction(result.tx).gasPrice.toNumber();
  // Executes in the VM but don't get mined to blockchain and report consumed gas.
  let gas = await MyContract.function.estimateGas(payload); 
  ...
}

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.