How to use the web3-eth-abi.decodeParameter 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 kioskprotocol / contracts / test / standardmarket.js View on Github external
before(async () => {
        market = await StandardMarket.deployed();
        registry = await DINRegistry.deployed();
        orders = await Orders.deployed();

        const registryUtils = await DINRegistryUtils.deployed();

        // Register 2 new DINs to the merchant
        const result = await registryUtils.selfRegisterDINs(2);
        const logs = result.receipt.logs;

        DIN1 = parseInt(ABI.decodeParameter("uint256", logs[0].topics[1]), 10);
        DIN2 = parseInt(ABI.decodeParameter("uint256", logs[1].topics[1]), 10);
    });
github magmo / apps / packages / server / src / hub / services / rps-commitment.ts View on Github external
export function decodeAppAttributes(appAttrs: string): RPSAppAttributes {
  const parameters = abi.decodeParameter(SolidityRPSCommitmentType, appAttrs);
  return {
    positionType: parseInt(parameters[0], 10),
    stake: parameters[1],
    preCommit: parameters[2],
    bWeapon: parseInt(parameters[3], 10),
    aWeapon: parseInt(parameters[4], 10),
    salt: parameters[5],
  };
}
github vechain / thorify / src / provider / rpc-methods.ts View on Github external
} else {
            reqBody.gas = parseInt(utils.sanitizeHex(rpc.params[0].gas), 16)
        }
    }
    if (rpc.params[0].from) {
        reqBody.caller = rpc.params[0].from
    }

    const res = await HTTP.post(URL, reqBody, timeout).then(HTTPPostProcessor)

    if (!res) {
        return rpc.makeResult(null)
    } else {
        if (res.reverted || res.vmError) {
            if (res.data && (res.data as string).startsWith('0x08c379a0')) {
                debug('VM reverted with message:', require('web3-eth-abi').decodeParameter('string', res.data.replace(/^0x08c379a0/i, '')))
            } else if (res.vmError) {
                debug('VM returned error:', res.vmError)
            }
            return rpc.makeResult(null)
        } else {
            return rpc.makeResult(res.data === '0x' ? '' : res.data)
        }
    }
})
github magmo / apps / packages / rps / src / core / rps-commitment.ts View on Github external
function decodeAppAttributes(appAttrs: string): AppAttributes {
  const parameters = abi.decodeParameter(SolidityRPSCommitmentType, appAttrs);
  return {
    positionType: parameters[0] as PositionType,
    stake: parameters[1],
    preCommit: parameters[2],
    bWeapon: parameters[3] as Weapon,
    aWeapon: parameters[4] as Weapon,
    salt: parameters[5],
  };
}