How to use the web3-eth-abi.encodeParameter 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 likecoin / likecoin-contracts / test / gas.js View on Github external
function encodeMock2(to, value, key) {
  const bytesBuf = ['0x'];
  bytesBuf.push(web3Abi.encodeParameter('address', to).substr(2 + (12 * 2)));
  bytesBuf.push(web3Abi.encodeParameter('uint256', value).substr(2));
  bytesBuf.push(web3Abi.encodeParameter('bytes32', key).substr(2));
  return bytesBuf.join('');
}
github likecoin / likecoin-contracts / test / gas.js View on Github external
function encodeMock2(to, value, key) {
  const bytesBuf = ['0x'];
  bytesBuf.push(web3Abi.encodeParameter('address', to).substr(2 + (12 * 2)));
  bytesBuf.push(web3Abi.encodeParameter('uint256', value).substr(2));
  bytesBuf.push(web3Abi.encodeParameter('bytes32', key).substr(2));
  return bytesBuf.join('');
}
github magmo / apps / packages / server / src / hub / services / rps-commitment.ts View on Github external
export function encodeAppAttributes(appAttrs: RPSAppAttributes): Bytes {
  const { positionType, stake, preCommit, bWeapon, aWeapon, salt } = appAttrs;
  return abi.encodeParameter(SolidityRPSCommitmentType, [
    positionType,
    stake,
    preCommit,
    bWeapon,
    aWeapon,
    salt,
  ]);
}
github AztecProtocol / AZTEC / packages / typed-data / src / index.js View on Github external
return types[primaryType].reduce((acc, { name, type }) => {
        if (types[type]) {
            return `${acc}${sliceKeccak256(`0x${encodeMessageData(types, type, message[name])}`)}`;
        }
        if (type === 'string' || type === 'bytes') {
            return `${acc}${sliceKeccak256(message[name])}`;
        }
        if (type.includes('[')) {
            return `${acc}${sliceKeccak256(AbiCoder.encodeParameter(type, message[name]))}`;
        }
        return `${acc}${AbiCoder.encodeParameters([type], [message[name]]).slice(2)}`;
    }, sliceKeccak256(signer.encodeStruct(primaryType, types)));
};
github merklejerk / flex-contract / src / coder.js View on Github external
function encodeParameter(type, value) {
	assert(!_.isNil(value));
	return abiEncoder.encodeParameter(type, normalizeEncodeValue(type, value));
}