Created
December 23, 2019 13:31
-
-
Save helderjnpinto/099751aedce90ebf8bdf47901a80eca0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
calcIntrinsic: encodedData => { | |
const txFee = new BigNumber('21000') | |
encodedData = hexToBytes(encodedData) | |
let countNonZeros = 0 | |
let countZeros = 0 | |
for (let i = 0; i < encodedData.length; i++) { | |
const dataElement = encodedData[i] | |
if (dataElement == '0') { | |
++countZeros | |
} | |
} | |
countNonZeros = encodedData.length - countZeros | |
countZerosTotal = new BigNumber(countZeros.toString()).times(new BigNumber('4')) | |
countNonZerosTotal = new BigNumber(countNonZeros.toString()).times(new BigNumber('16')) | |
return txFee.plus(countZerosTotal).plus(countNonZerosTotal) | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment