is there any way by which i can convert a string which is in this form:

string: "0xbajdu2ajaj72uw82jdhjska"

to

address: 0xbajdu2ajaj72uw82jdhjska

Wether the method is in js, or solidity... It would be more helpful if it is in js but solidity will also work.

Using: truffle, Web3js

Jun 13, 2022, 5:46 PM
How else would you represent an address in js if not as a string?
Jun 13, 2022, 5:47 PM
I literally have no idea... Just asking if there's any method in web3.utils or something.
Or if it coudl be converted to address in solidity.
Jun 13, 2022, 6:44 PM
In js, you're already done. It's an address already. Congrats
In solidity... Good luck
It's gonna be quite costly to convert a string containing a hex number to an address
Jun 13, 2022, 6:48 PM
So, all hopes lost.... In js...
Lets try this also๐Ÿ˜”....
Jun 13, 2022, 6:50 PM
Whut
Jun 13, 2022, 6:50 PM
JavaScript doesn't have an address data type so just pass your address string value to any methods that requires an address as an argument in solidity
Jun 13, 2022, 6:54 PM
But then it says the parameter passed is something else not address to be specific.
Jun 13, 2022, 7:23 PM
Pass the address to this method if it returns true web3.utils.isAddress("your address")
Jun 13, 2022, 7:27 PM
this return true.
Jun 13, 2022, 9:02 PM
Congrats, you got your address. As in: what you passed to that function already is considered an address
Jun 13, 2022, 9:07 PM
So, Now its upto solidity to consider my request ๐Ÿ˜
Jun 13, 2022, 9:08 PM

ยฉ 2024 Draquery.com All rights reserved.