How to use ethereumjs-abi - 10 common examples

To help you get started, we’ve selected a few ethereumjs-abi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hyperledger / burrow / js / lib / contracts / function.js View on Github external
var encodeF = function (abi, args, bytecode) {
  if (abi) {
    var abiInputs = types(abi.inputs)
    args = convert.burrowToAbi(abiInputs, args) // If abi is passed, convert values accordingly
  }

  // If bytecode provided then this is a creation call, bytecode goes first
  if (bytecode) {
    var data = bytecode
    if (abi) data += convert.bytesTB(coder.rawEncode(abiInputs, args))
    return data
  } else {
    return functionSig(abi) + convert.bytesTB(coder.rawEncode(abiInputs, args))
  }
}
github PolymathNetwork / polymath-core / test / helpers / encodeCall.js View on Github external
export function encodeProxyCall(parametersType, values) {
    const methodId = abi.methodID("initialize", parametersType).toString("hex");
    const params = abi.rawEncode(parametersType, values).toString("hex");
    return "0x" + methodId + params;
}
github centrehq / centre-tokens / test / TokenTestUtils.js View on Github external
function encodeCall(name, arguments, values) {
    const methodId = abi.methodID(name, arguments).toString('hex');
    const params = abi.rawEncode(arguments, values).toString('hex');
    return '0x' + methodId + params;
}
github OffchainLabs / arbitrum / test / arb / vm-machine.js View on Github external
hash() {
		return '0x' + abi.soliditySHA3(
			['bytes32', 'bytes32', 'bytes32', 'bytes32', 'bytes32'],
			[
				this.instructionStack.hash(),
				this.dataStack.hash(),
				this.callStack.hash(),
				this.registerVal.hash(),
				this.staticVal.hash()
			]).toString('hex');
	}
}
github AdChain / AdChainRegistryDapp / src / services / redditActions.js View on Github external
export async function createComment (id, comment, address) {
  let res
  let userHash = `0x${soliditySHA3(['string'], [address]).toString('hex')}`
  let user = address === 'anonymous' ? address : userHash.substr(2, 7)

  try {
    res = await axios.post(`${utilityApiURL}/create/comment`, {
      id: id,
      comment: comment,
      address: user
    })
    return res
  } catch (error) {
    console.error(error)
  }
}
github unstoppabledomains / browseth / src / abi.ts View on Github external
encode(...params: any[]) {
            return (
              '0x' + signature + Abi.rawEncode(iTypes, params).toString('hex')
            );
          },
          decode(raw: string) {
github AudiusProject / audius-protocol / eth-contracts / migrations / 4_staking.js View on Github external
function encodeCall (name, args, values) {
  const methodId = abi.methodID(name, args).toString('hex')
  const params = abi.rawEncode(args, values).toString('hex')
  return '0x' + methodId + params
}
github AugurProject / augur / packages / augur-utils / src / abi-encode-data.ts View on Github external
export function abiEncodeData(payload, format = "") {
  let abiEncodedData = ethereumjsAbi.rawEncode(payload.signature || [], payload.params);
  if (format === "hex") return "0x" + abiEncodedData.toString("hex");
  return abiEncodedData;
}
github OriginTrail / ot-node / modules / Encryption.js View on Github external
static generateHash(dataArgs) {
        const types = [];
        const args = [];

        for (const value of dataArgs) {
            types.push('uint256');
            args.push(new BN(value, 16));
        }
        return Utilities.normalizeHex(abi.soliditySHA3(types, args).toString('hex').padStart(64, '0'));
    }
github unstoppabledomains / browseth / src / common / crypto.ts View on Github external
export function tightlyPackedKeccak256(
  inputTypes: string[],
  ...messages: any[]
) {
  return '0x' + soliditySHA3(inputTypes, messages).toString('hex');
}

ethereumjs-abi

Decoder and encoder for the Ethereum ABI

MIT
Latest version published 5 years ago

Package Health Score

58 / 100
Full package analysis