How to use the web3-utils.toChecksumAddress function in web3-utils

To help you get started, we’ve selected a few web3-utils 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 OriginProtocol / origin / infra / notifications / src / emailSend.js View on Github external
)

    // Load the sender's identity and construct the best human readable
    // version of sender name.
    const senderIdentity = await Identity.findOne({
      where: {
        ethAddress: sender
      }
    })
    const senderName =
      senderIdentity !== null &&
      senderIdentity.firstName &&
      senderIdentity.lastName
        ? `${senderIdentity.firstName || ''} ${senderIdentity.lastName ||
            ''} (${web3Utils.toChecksumAddress(sender)})`
        : web3Utils.toChecksumAddress(sender)

    // Dynamic variables used when evaluating the template.
    const templateVars = {
      config: this.config,
      sender,
      senderName,
      dappUrl: this.config.dappUrl,
      ipfsGatewayUrl: this.config.ipfsGatewayUrl,
      messageHash
    }

    // Load the identities of all the receivers.
    const identities = await Identity.findAll({
      where: { ethAddress: { [Sequelize.Op.or]: receivers } }
    })
github ethereum / web3.js / packages / web3-eth-personal / src / index.js View on Github external
set: function (val) {
            if(val) {
                defaultAccount = utils.toChecksumAddress(formatters.inputAddressFormatter(val));
            }

            // update defaultBlock
            methods.forEach(function(method) {
                method.defaultAccount = defaultAccount;
            });

            return val;
        },
        enumerable: true
github ethereum / web3.js / packages / web3-core-helpers / src / formatters.js View on Github external
tx.blockNumber = utils.hexToNumber(tx.blockNumber);
    if (tx.transactionIndex !== null)
        tx.transactionIndex = utils.hexToNumber(tx.transactionIndex);
    tx.nonce = utils.hexToNumber(tx.nonce);
    tx.gas = utils.hexToNumber(tx.gas);
    tx.gasPrice = outputBigNumberFormatter(tx.gasPrice);
    tx.value = outputBigNumberFormatter(tx.value);

    if (tx.to && utils.isAddress(tx.to)) { // tx.to could be `0x0` or `null` while contract creation
        tx.to = utils.toChecksumAddress(tx.to);
    } else {
        tx.to = null; // set to `null` if invalid address
    }

    if (tx.from) {
        tx.from = utils.toChecksumAddress(tx.from);
    }

    return tx;
};
github aragon / aragon-court / test / helpers / asserts / assertEvent.js View on Github external
const assertEvent = (receipt, eventName, expectedArgs = {}, index = 0) => {
  const event = getEventAt(receipt, eventName, index)

  assert(typeof event === 'object', `could not find an emitted ${eventName} event ${index === 0 ? '' : `at index ${index}`}`)

  for (const arg of Object.keys(expectedArgs)) {
    let foundArg = event.args[arg]
    if (isBN(foundArg)) foundArg = foundArg.toString()
    if (isAddress(foundArg)) foundArg = toChecksumAddress(foundArg)

    let expectedArg = expectedArgs[arg]
    if (isBN(expectedArg)) expectedArg = expectedArg.toString()
    if (isAddress(foundArg)) expectedArg = toChecksumAddress(expectedArg)

    assert.equal(foundArg, expectedArg, `${eventName} event ${arg} value does not match`)
  }
}
github 0xbitcoin / tokenpool / lib / util / contract-helper.js View on Github external
getMintHelperAddress(pool_env)
       {
         var address;
         if(pool_env == 'test')
         {
           address =  deployedContractInfo.networks.testnet.contracts.mintforwarder.blockchain_address;
         }else if(pool_env == 'staging'){
           address =  deployedContractInfo.networks.staging.contracts.mintforwarder.blockchain_address;
         }else if(pool_env == 'production'){
           address =  deployedContractInfo.networks.mainnet.contracts.mintforwarder.blockchain_address;
         }
         return web3utils.toChecksumAddress(address)
         console.error('no pool env set', pool_env)
       },
github autonomoussoftware / metronome-wallet-desktop / src / components / common / receipt / Receipt.js View on Github external
)}

          {tx.txType === 'received' && tx.from && (
            
              <label>
                {this.props.isPending ? 'Pending' : 'Received'} from
              </label>
              <address>{toChecksumAddress(tx.from)}</address>
            
          )}

          {tx.txType === 'sent' &amp;&amp; tx.to &amp;&amp; (
            
              <label>{this.props.isPending ? 'Pending' : 'Sent'} to</label>
              <address>{toChecksumAddress(tx.to)}</address>
            
          )}

          {tx.txType === 'exported' &amp;&amp; tx.exportedTo &amp;&amp; (
            
              <label>{this.props.isPending ? 'Pending' : 'Exported'} to</label>
              {tx.exportedTo} blockchain
            
          )}

          {tx.txType === 'import-requested' &amp;&amp; tx.importedFrom &amp;&amp; (
            
              <label>
                {this.props.isPending
                  ? 'Pending import request'
                  : 'Import requested'}{' '}</label>
github melonproject / protocol / src / utils / types.ts View on Github external
constructor(address: string) {
    if (!isAddress(address)) {
      throw new TypeError(`Invalid address ${address}`);
    }

    super(Web3Utils.toChecksumAddress(address));
  }
}
github MyEtherWallet / MyEtherWallet / src / layouts / InterfaceLayout / components / InterfaceTokens / InterfaceTokens.vue View on Github external
const searchCustom = this.customTokens.find(item => {
        return (
          utils.toChecksumAddress(item.address) ===
          utils.toChecksumAddress(addr)
        );
      });
github AztecProtocol / AZTEC / packages / aztec.js / src / secp256k1 / index.js View on Github external
secp256k1.ecdsa.accountFromPublicKey = (publicKey) => {
    let publicHash;
    if (typeof publicKey === 'string') {
        publicHash = web3Utils.sha3(`0x${publicKey.slice(4)}`);
    } else {
        const ecKey = secp256k1.ec.keyFromPublic(publicKey);
        const publicKeyHex = `0x${ecKey.getPublic(false, 'hex').slice(2)}`;
        publicHash = web3Utils.sha3(publicKeyHex);
    }
    const address = web3Utils.toChecksumAddress(`0x${publicHash.slice(-40)}`);
    return address;
};