How to use the web3-eth-abi.encodeFunctionSignature function in web3-eth-abi

To help you get started, we’ve selected a few web3-eth-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 aragon / aragon-cli / packages / toolkit / src / dao / encodeActCall.js View on Github external
export default (signature, params = []) => {
  const sigBytes = abi.encodeFunctionSignature(signature)

  const types = signature.replace(')', '').split('(')[1]

  // No params, return signature directly
  if (types === '') {
    return sigBytes
  }

  const paramBytes = abi.encodeParameters(types.split(','), params)

  return `${sigBytes}${paramBytes.slice(2)}`
}
github aragon / aragon-cli / packages / aragon-cli / src / commands / dao_cmds / act.js View on Github external
const encodeCalldata = (signature, params) => {
  const sigBytes = ABI.encodeFunctionSignature(signature)

  const types = signature.replace(')', '').split('(')[1]

  // No params, return signature directly
  if (types === '') {
    return sigBytes
  }

  const paramBytes = ABI.encodeParameters(types.split(','), params)

  return `${sigBytes}${paramBytes.slice(2)}`
}
github melonproject / protocol / src / contracts / fund / trading / calls / isOasisDexTakePermitted.ts View on Github external
//   makerQuantity.quantity,
  //   takerQuantity.quantity,
  // ).call();

  const policyManager = await getContract(
    environment,
    Contracts.PolicyManager,
    policyManagerAddress,
  );

  const exchangeAddress =
    environment.deployment.exchangeConfigs[Exchanges.MatchingMarket].exchange;

  const result = await policyManager.methods
    .preValidate(
      web3EthAbi.encodeFunctionSignature(FunctionSignatures.takeOrder),
      [
        '0x0000000000000000000000000000000000000000', // orderAddresses[0],
        tradingAddress.toString(), // orderAddresses[1],
        makerQuantity.token.address.toString(), // orderAddresses[2],
        takerQuantity.token.address.toString(), // orderAddresses[3],
        exchangeAddress.toString(), // exchanges[exchangeIndex].exchange
      ],
      [
        makerQuantity.quantity.toString(), // orderValues[0],
        takerQuantity.quantity.toString(), // orderValues[1],
        fillTakerTokenAmount.quantity.toString(), // orderValues[6]
      ],
      `0x${Number(id)
        .toString(16)
        .padStart(64, '0')}`, // identifier
    )
github melonproject / protocol / src / contracts / fund / trading / calls / isOasisDexMakePermitted.ts View on Github external
//   makerQuantity.quantity,
  //   takerQuantity.quantity,
  // ).call();

  const policyManager = await getContract(
    environment,
    Contracts.PolicyManager,
    policyManagerAddress,
  );

  const exchangeAddress =
    environment.deployment.exchangeConfigs[Exchanges.MatchingMarket].exchange;

  const result = await policyManager.methods
    .preValidate(
      web3EthAbi.encodeFunctionSignature(FunctionSignatures.makeOrder),
      [
        tradingAddress.toString(), // orderAddresses[0],
        '0x0000000000000000000000000000000000000000', // orderAddresses[1],
        makerQuantity.token.address.toString(), // orderAddresses[2],
        takerQuantity.token.address.toString(), // orderAddresses[3],
        exchangeAddress.toString(), // exchanges[exchangeIndex].exchange
      ],
      [
        makerQuantity.quantity.toString(), // orderValues[0],
        takerQuantity.quantity.toString(), // orderValues[1],
        '0', // orderValues[6]
      ],
      '0x0', // identifier
    )
    .call();
github melonproject / protocol / src / utils / abi / getFunctionABISignature.ts View on Github external
export const getFunctionABISignature = (abi: any, functionName: string) => {
  return Web3EthAbi.encodeFunctionSignature(
    findFunctionDefinition(abi, functionName),
  );
};
github melonproject / protocol / src / utils / constants / orderSignatures.ts View on Github external
function abiEncode(joinedSignature) {
  return web3EthAbi.encodeFunctionSignature(joinedSignature);
}
github aragon / radspec / src / index.js View on Github external
const method = call.abi.find((abi) =>
    abi.type === 'function' &&
    methodId === ABI.encodeFunctionSignature(abi))