package demo | |
import ( | |
"bytes" | |
"github.com/ethereum/go-ethereum/crypto" | |
"github.com/vechain/thor/thor" | |
"github.com/vechain/thor/tx" | |
) | |
func BuildVIP191Tx() *tx.Transaction { | |
originPrivateKey, _ := crypto.HexToECDSA("c962bfd916c0f8d4c1866b11a24802815cf58ba981354fad0ac734d0217cfe73") | |
delegatorPrivateKey, _ := crypto.HexToECDSA("dce1443bd2ef0c2631adc1c67e5c93f13dc23a41c18b536effbbdcbcdb96fb65") | |
origin := thor.Address(crypto.PubkeyToAddress(originPrivateKey.PublicKey)) | |
blockID, _ := thor.ParseBytes32("0x002b99c540c4e2674551edba709748e2f668b9b5ac18eba2f72a3af72d9a6734") | |
to, _ := thor.ParseAddress("0xd3ae78222beadb038203be21ed5ce7c9b1bff602") | |
unsigned := new(tx.Builder). | |
ChainTag(0x27). | |
BlockRef(tx.NewBlockRefFromID(blockID)). | |
Expiration(30 * 8640). | |
Clause(tx.NewClause(&to)). | |
Gas(21000). | |
Nonce(0xa2b5232b). // random number | |
Features(tx.DelegationFeature). // enable fee delegation | |
Build() | |
originSig, _ := crypto.Sign(unsigned.SigningHash().Bytes(), originPrivateKey) | |
delegatorSig, _ := crypto.Sign(unsigned.DelegatorSigningHash(origin).Bytes(), delegatorPrivateKey) | |
fullSig := bytes.Join([][]byte{originSig, delegatorSig}, nil) | |
signed := unsigned.WithSignature(fullSig) | |
return signed | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
Working Prefect @testnet ^^'