golang相关代码
```
func (n NFT) CalculateHash() ([]byte, error) {
b := new(big.Int)
b.SetString(n.tokenID, 10)
num := common.LeftPadBytes(b.Bytes(), 32)
hash := crypto.Keccak256Hash(common.HexToAddress(nAddress).Bytes(), num)
return hash.Bytes(), nil
}
hex := common.Bytes2Hex( tree.MerkleRoot())
fmt.Println("root:",hex)
path, _, _ := tree.GetMerklePath(list[0])
for _,v := range path {
hash := common.BytesToHash(v)
proof = append(proof, hash.String())
}
fmt.Println("proof",proof)
func (n NFT) CalculateHash() ([]byte, error) {
b := new(big.Int)
b.SetString(n.tokenID, 10)
num := common.LeftPadBytes(b.Bytes(), 32)
hash := crypto.Keccak256Hash(common.HexToAddress(nAddress).Bytes(), num)
return hash.Bytes(), nil
}
hex := common.Bytes2Hex( tree.MerkleRoot())
fmt.Println("root:",hex)
path, _, _ := tree.GetMerklePath(list[0])
for _,v := range path {
hash := common.BytesToHash(v)
proof = append(proof, hash.String())
}
fmt.Println("proof",proof)
```
生成的proof无法在合约端验证成功
合约代码参考https://mirror.xyz/qiwihui.eth/HRifb9gziR1UvVmRcMjDfDvQ9mq7o7FA6BNuCJMFT00
有疑问加站长微信联系(非本文作者)