How to use the web3-utils.bytesToHex 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 0xbitcoin / 0xbitcoin-token / test / mining-helper.js View on Github external
//  console.log('digestBigNumber',digestBigNumber.toString())
              // console.log('miningTarget',miningTarget.toString())

                 if ( digestBigNumber.lt(miningTarget) )
                 {


                    console.log(minerEthAddress)
                     console.log('------')
                     console.log(solution_number)
                      console.log(challenge_number)
                        console.log(solution_number)
                    console.log('------')
                     console.log( web3utils.bytesToHex(digestBytes32))
                 }


             if ( digestBigNumber.lt(miningTarget)  )
             {
               //pass in digest bytes or trimmed ?

               if(this.testMode){
                 this.mining = false;

                 this.networkInterface.checkMiningSolution( minerEthAddress, solution_number , web3utils.bytesToHex( digestBytes32 ),challenge_number,miningTarget,
                   function(result){
                    console.log('checked mining soln:' ,result)
                  })
              }else {
                console.log('submit mined solution with challenge ', challenge_number)
github JoinColony / tailor / src / modules / utils / sigHexToRSV.js View on Github external
// NOTE: with potential introduction of chainId this might need to be updated
  if (sig.length !== 65) {
    throw new Error('Invalid signature length');
  }

  let v = sig[64];
  // support both versions of `eth_sign` responses
  if (v < 27) {
    v += 27;
  }

  return {
    v,
    r: bytesToHex(sig.slice(0, 32)),
    s: bytesToHex(sig.slice(32, 64)),
  };
}
github JoinColony / tailor / src / modules / utils / sigHexToRSV.js View on Github external
const sig = hexToBytes(sigString);

  // NOTE: with potential introduction of chainId this might need to be updated
  if (sig.length !== 65) {
    throw new Error('Invalid signature length');
  }

  let v = sig[64];
  // support both versions of `eth_sign` responses
  if (v < 27) {
    v += 27;
  }

  return {
    v,
    r: bytesToHex(sig.slice(0, 32)),
    s: bytesToHex(sig.slice(32, 64)),
  };
}
github fairDataSociety / fds.js / lib / FDS-SwarmFeeds.js View on Github external
view.setUint8(cursor, v);
            cursor++;
        });

        // time is little-endian
        view.setUint32(cursor, metaResponse.epoch.time, true);
        cursor += 7;

        view.setUint8(cursor, metaResponse.epoch.level);
        cursor++;

        dataBytes.forEach((v) => {
            view.setUint8(cursor, v);
            cursor++;
        });
        return sha3(padLeft(bytesToHex(new Uint8Array(buf)),264));
    }
github trufflesuite / truffle / packages / external-compile / index.js View on Github external
function decodeContents(contents) {
  // JSON
  try {
    return JSON.parse(contents);
  } catch (e) {
    /* no-op */
  }

  // hex string
  if (contents.toString().startsWith("0x")) {
    return contents.toString();
  }

  // raw binary
  return web3Utils.bytesToHex(contents);
}
github 0xbitcoin / 0xbitcoin-token / test / mining-helper.js View on Github external
console.log(solution_number)
                      console.log(challenge_number)
                        console.log(solution_number)
                    console.log('------')
                     console.log( web3utils.bytesToHex(digestBytes32))
                 }


             if ( digestBigNumber.lt(miningTarget)  )
             {
               //pass in digest bytes or trimmed ?

               if(this.testMode){
                 this.mining = false;

                 this.networkInterface.checkMiningSolution( minerEthAddress, solution_number , web3utils.bytesToHex( digestBytes32 ),challenge_number,miningTarget,
                   function(result){
                    console.log('checked mining soln:' ,result)
                  })
              }else {
                console.log('submit mined solution with challenge ', challenge_number)
                console.log('submit mined solution with solution ', solution_number)
                this.submitNewMinedBlock( minerEthAddress, solution_number,   web3utils.bytesToHex( digestBytes32 ) , challenge_number);
              }
             }


  },
github 0xbitcoin / 0xbitcoin-miner / 0xbitcoinminer.js View on Github external
//console.log('digestBigNumber',digestBigNumber.toString())
                 //console.log('miningTarget',miningTarget.toString())

               if ( digestBigNumber.lt(miningTarget)  )
               {

                  if(this.testMode){
                    console.log(minerEthAddress)
                    console.log('------')
                    console.log(solution_number)
                    console.log(challenge_number)
                    console.log(solution_number)
                    console.log('------')
                    console.log( web3utils.bytesToHex(digestBytes32))

                 //pass in digest bytes or trimmed ?


                   this.mining = false;

                   /*this.networkInterface.checkMiningSolution( minerEthAddress, solution_number , web3utils.bytesToHex( digestBytes32 ),challenge_number,miningTarget,
                     function(result){
                      console.log('checked mining soln:' ,result)
                    })*/


                  }else {
                    console.log('submit mined solution with challenge ', challenge_number)

                    this.submitNewMinedBlock( addressFrom, minerEthAddress, solution_number,   web3utils.bytesToHex( digestBytes32 ) , challenge_number, target, difficulty );
github OpenZeppelin / openzeppelin-gsn-provider / src / tabookey-gasless / utils.js View on Github external
reject(e);
        }
      });
    } catch (e) {
      sig_ = await new Promise((resolve, reject) => {
        web3.eth.sign(hash, account, (err, res) => {
          if (err) reject(err);
          else resolve(res);
        });
      });
    }

    let signature = ethUtils.fromRpcSig(sig_);
    let sig =
      web3Utils.bytesToHex(signature.r) +
      removeHexPrefix(web3Utils.bytesToHex(signature.s)) +
      removeHexPrefix(web3Utils.toHex(signature.v));

    return sig;
  },
github fairDataSociety / fds.js / lib / FDS-SwarmStore.js View on Github external
return this.SF.get(address, key, 'arraybuffer').then((t) => {
            let ivAndEncryptedString = bytesToHex(encryptedBuffer);
            let iv = ivAndEncryptedString.substring(0, 34);
            let encryptedString = ivAndEncryptedString.substring(34);
            return Crypto.decryptString(encryptedString, password, iv);
        });
    }