How to use the abi-decoder.decodeMethod function in abi-decoder

To help you get started, we’ve selected a few abi-decoder 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 sponnet / peepin / src / peepin.js View on Github external
.then(transaction => {
        if (transaction.blockNumber > this.highestBlock) {
          this.lastReadBlock = transaction.blockNumber;
        }
        if (!transaction.input) {
          return logger.error(new Error("no transaction input found"));
        }
        let decodedData;
        try {
          decodedData = abiDecoder.decodeMethod(transaction.input);
        } catch (e) {
          return logger.error(e);
        }
        this.eventCount++;

        if (!decodedData || !decodedData.name) {
          return logger.error(new Error("error decoding method"));
        }

        // updateAccount(_ipfsHash string)
        // reply(_ipfsHash string)
        // share(_ipfsHash string)
        // saveBatch(_ipfsHash string)
        // post(_ipfsHash string)
        // createAccount(_name bytes16,_ipfsHash string)
        // tip(_author address,_messageID string,_ownerTip uint256,_ipfsHash string)
github secret-tech / backend-ico-dashboard / src / services / transaction.service.ts View on Github external
getFromToTokenAmountByTxDataAndType(txData: any, type: string): FromToTokenAmount {
    let from = this.web3.utils.toChecksumAddress(txData.from);
    let to = null;
    let tokenAmount = null;

    // direct transfer calls of tokens
    if (type === TOKEN_TRANSFER) {
      abiDecoder.addABI(config.contracts.token.abi);
      const decodedData = abiDecoder.decodeMethod(txData.input);
      if (decodedData.name === 'transfer') {
        to = this.web3.utils.toChecksumAddress(decodedData.params[0].value);
        tokenAmount = this.web3.utils.fromWei(decodedData.params[1].value).toString();
      }
    } else if (txData.to) {
      to = this.web3.utils.toChecksumAddress(txData.to);
    }

    return {
      from,
      to,
      tokenAmount
    };
  }
github descampsk / wavevote / WaveVote_NodeJsServer / js / elasticNodejsServer.js View on Github external
index: 'transaction',
			  type: 'block',
			  id: block.number,
			  body: json
			}, function (error, response) {
			  console.log(error);
			  console.log(response);
			});
		
		
		if(transactionList.length!==0) {
			for(var j=0;j
github theoephraim / ethdevtools / src / devtools / assets / utils.js View on Github external
eth_call: (args, _, contracts) => {
    console.log('eth_call');
    console.log(args);
    const contractAddress = `${args[1][0].to.toLowerCase()}`;
    const methodSig = args[1][0].data.slice(0, 10);

    let decodedInput; let name; let
      params;

    if (contracts[contractAddress]) {
      abiDecoder.addABI(contracts[contractAddress].abi);
      decodedInput = abiDecoder.decodeMethod(methodSig);
      name = `${decodedInput.name}(${decodedInput.params.map((p) => p.type).join(',')})`;
      params = decodedInput.params.length ? decodedInput.params : null;
    } else {
      name = methodSig;
      params = methodSig;
    }
    const foo = {
      to: contractAddress,
      name,
      params,
    };
    console.log('add eth call with this data', foo);
    return foo;
  },
  eth_gasPrice: (args) => {
github XinFinOrg / BlockDegree / server / listeners / txnConfirmation.js View on Github external
paymentId,
  userEmail,
  tokenName
) {
  switch (tokenName) {
    case "xdce": {
      try {
        const web3 = new Web3(
          new Web3.providers.WebsocketProvider("wss://mainnet.infura.io/ws")
        );

        let course = await CoursePrice.findOne({ courseId: courseId });
        let getTx = await web3.eth.getTransaction(txHash);
        let paymentLog = await PaymentToken.findOne({ payment_id: paymentId });
        let txInputData = getTx.input;
        let decodedMethod = abiDecoder.decodeMethod(txInputData);
        let receivedXdce = decodedMethod.params[1].value;

        const contractInst = new web3.eth.Contract(xdceABI, xdceAddrMainnet);


        
        const allWallet = await AllWallet.findOne({
          burnActive: {
            $elemMatch: {
              wallet_network: paymentLog.payment_network,
              wallet_token_name: tokenName
            }
          }
        });

        let xdceOwnerPubAddr = null;
github airgap-it / airgap-coin-lib / lib / protocols / GenericERC20.ts View on Github external
getTransactionDetailsFromSigned(signedTx: SignedEthereumTransaction): IAirGapTransaction {
    const ethTx = super.getTransactionDetailsFromSigned(signedTx)

    const extractedTx = new EthereumTransaction(signedTx.transaction)
    const tokenTransferDetails = abiDecoder.decodeMethod('0x' + extractedTx.data.toString('hex'))
    ethTx.to = [ethUtil.toChecksumAddress(tokenTransferDetails.params[0].value)]
    ethTx.amount = new BigNumber(tokenTransferDetails.params[1].value)

    return ethTx
  }
github OpenZeppelin / openzeppelin-gsn-provider / src / tabookey-gasless / RelayClient.js View on Github external
var tx = new ethJsTx({
            nonce: returned_tx.nonce,
            gasPrice: returned_tx.gasPrice,
            gasLimit: returned_tx.gas,
            to: returned_tx.to,
            value: returned_tx.value,
            data: returned_tx.input,
        });

        let message = tx.hash(false);
        let tx_v = Buffer.from(removeHexPrefix(returned_tx.v), "hex");
        let tx_r = Buffer.from(padTo64(removeHexPrefix(returned_tx.r)), "hex");
        let tx_s = Buffer.from(padTo64(removeHexPrefix(returned_tx.s)), "hex");

        let signer = ethUtils.bufferToHex(ethUtils.pubToAddress(ethUtils.ecrecover(message, tx_v[0], tx_r, tx_s)));
        let request_decoded_params = abi_decoder.decodeMethod(returned_tx.input).params;
        let returned_tx_params_hash = utils.getTransactionHash(
            request_decoded_params[0].value,
            request_decoded_params[1].value,
            request_decoded_params[2].value,
            request_decoded_params[3].value,
            request_decoded_params[4].value,
            request_decoded_params[5].value,
            request_decoded_params[6].value,
            returned_tx.to,
            signer
        );
        let transaction_orig_params_hash = utils.getTransactionHash(
            from, to, transaction_orig, transaction_fee, gas_price, gas_limit, nonce, relay_hub_address, relay_address);

        if (returned_tx_params_hash === transaction_orig_params_hash && address_relay === signer) {
            if (this.config.verbose) {

abi-decoder

Nodejs and Javascript library for decoding data params and events from ethereum transactions"

GPL-3.0
Latest version published 4 years ago

Package Health Score

47 / 100
Full package analysis