question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

formatBytes32String: TypeError: e is null

See original GitHub issue

I am trying to converting a value from string to bytes32, for save to Ethereum. The program that has no problems so far, now report this error;

TypeError: e is null
o
node_modules/ethers/dist/ethers.min.js:1

> 1 | !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).ethers=e()}}(function(){return function o(s,a,u){function l(t,e){if(!a[t]){if(!s[t]){var r="function"==typeof require&&require;if(!e&&r)return r(t,!0);if(h)return h(t,!0);var n=new Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}var i=a[t]={exports:{}};s[t][0].call(i.exports,function(e){return l(s[t][1][e]||e)},i,i.exports,o,s,a,u)}return a[t].exports}for(var h="function"==typeof require&&require,e=0;e<u.length;e++)l(u[e]);return l}({1:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.version="4.0.47"},{}],2:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./utils/properties"),i=(o.isSigner=function(e){return n.isType(e,"Signer")},o);function o(){n.setType(this,"Signer")}r.Signer=i},{"./utils/properties":74}],3:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./utils/bignumber");r.AddressZero="0x0000000000000000000000000000000000000000";r.HashZero="0x0000000000000000000000000000000000000000000000000000000000000000";r.EtherSymbol="\u039e";var i=n.bigNumberify(-1);r.NegativeOne=i;var o=n.bigNumberify(0);r.Zero=o;var s=n.bigNumberify(1);r.One=s;var a=n.bigNumberify(2);r.Two=a;var u=n.bigNumberify("1000000000000000000");r.WeiPerEther=u;var l=n.bigNumberify("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");

I am working on React, and using ethers like this:

        async function submit() {
          //  setAuth(authe.isLoading{true})
            // var valuesBuffer = Buffer.from(JSON.stringify(values)); //values.ETHaddress + values.username + ipfsHash
            var usnameByte32 = ethers.utils.formatBytes32String(values.username);

            web3.eth.defaultAccount = accounts[0]

            patientstorage.deployed().then(function(contractInstance){
              contractInstance.hasPatient(addre).then(function(v){
                console.log(v);
                if(v===true){
                  console.log("has patient address:",v);
                //   contractInstance.getPatientNameByAddress(values.ETHaddress).then(function(vv){
                  contractInstance.getPatientNameByAddress(addre).then(function(vv){
                    console.log("In the getPatientNameByAddress",vv)
                    if(usnameByte32 === vv){
                      console.log("Patient login:", true)
                      // if true Link to account personal page
                      localStorage.setItem('p',values.username,)
                      console.log(localStorage.getItem('userlogined'))
                      auth.login( () =>{
                        props.history.push('/home')
                      });
                    }
                  })
                }
              })
            })

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ricmoocommented, Apr 26, 2020

Can you include the result of console.log(values.username, typeof(values.username)) before the call to formatBytes32String? Also, what version of ethers are you using?

0reactions
Ekestfacommented, Apr 26, 2020

Importing ethers: import {ethers} from ethers For the submit function shown above, get values.username according to handleChange. Null values cannot be obtained here, but ethers are used outside of this function in other module, and this fault caused by this. Sorry for took your time. Thank you for your attention.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: e is null error - Stack Overflow
I am currently trying to put the results of an AJAX GET request into a table for an app under development in PhoneGap....
Read more >
TypeError: e is null · Issue #28969 · twbs/bootstrap - GitHub
Then something in your pipeline is causing this. We can't debug your environment hence why we ask for a reduced test case.
Read more >
JavaScript errors after clean install (TypeError: e is null ...
flash is null) After this error, all control panel dissapears so I can't do anything. I tried with npm run dev but nothing...
Read more >
Uncaught TypeError: e is null - error when saving edit event ...
I believe the problem is that the function doesn't handle properly the condition if e is null. Since we're changing the recurrence params...
Read more >
TypeError: e is null (in pages and posts) - WordPress.org
Hi, in the console I have this error. This happens in any page/post and is breaking other plugins. Any idea where it comes...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found