Hot answers tagged

3

The values you're showing are 32 bytes long (256 bits), not 64 bits. They're that length because the type is bytes32. The number 1 is different from 10, and the same holds in hexadecimal. You can't just drop the trailing zeros without changing the value. Assuming you're always working with strings, you could use web3.toAscii... e.g. assert.toEqual(web3....


2

The red flag here is of course that you are using web3.toAscii to convert Chinese, Korean, etc. Ascii by default is restricted to the English language. Solidity supports utf-8 and yes you can get and read names which are in utf-8 encoding (which allows non-English characters). The solution is to encode into utf-8 and then rest is all covered by web3. var ...


2

If you convert the integer 10 to its hexadecimal representation, you get 0xA. Fill that with enough zeros to get the string you need: >>> hex_str = "0x{:064x}".format(10) >>> print(hex_str) '0x000000000000000000000000000000000000000000000000000000000000000a'


2

Transactions are encoded based on the Contract ABI Specification. It is hard to get through, but these docs have all the answers to your question. The transaction in question is passing in two parameters: a dynamic string (name) and a static bool (isFirst). When encoding the parameters, the EVM looks to see if the parameters are static or dynamic. Static ...


1

Here's a full example of decoding the log topic to get the value (in your case the ID as an uint64): package main import ( "context" "fmt" "log" "math/big" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethclient" ) func main() { client, err := ethclient.Dial("https://mainnet.infura.io") if err !=...


Only top voted, non community-wiki answers of a minimum length are eligible