Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

send any action of transaction to blockchain, actually all action is crateAccount action #5

Open
raojianli opened this issue Mar 8, 2022 · 0 comments

Comments

@raojianli
Copy link

raojianli commented Mar 8, 2022

explore url: https://explorer.testnet.near.org/transactions/Co7SZ66NLZyiHbDfPNNHHCHQKureJFEb1NN8DX7Aryu4

code below:
`
privBytes, err := hex.DecodeString("c4ac861731eac8950b6608a0d03c478dca61a0b10af64e1e9b9b3990916d674d300743d2190a02a364621ca11c90bf02d29ffef815ef6801fbab727cb40ae34e")
if err!=nil{
panic(err)
}
privateKey := ed25519.PrivateKey(privBytes)

publicKey := privateKey.Public().(ed25519.PublicKey)
latestBlock, err := client.getLatestBlock()
if err!=nil{
	panic(err)
}
pubk := base58.Encode(publicKey)
fmt.Println("pubKey:",pubk)
amountBig, ok := big.NewInt(0).SetString("500000000000000000000000000",10)
if !ok{
	panic(ok)
}
hashBytes := base58.Decode(latestBlock.Header.Hash)

tx := createTransaction("300743d2190a02a364621ca11c90bf02d29ffef815ef6801fbab727cb40ae34e", utils.PublicKeyFromEd25519(publicKey), "qzx01.testnet", 84476352000013, hashBytes, []Action{{
	Transfer: Transfer{
		Deposit: *amountBig,
	},
}})
txHash, signedTx, err := signTransactionObject(tx, privateKey)
if err != nil {
	panic(err)
}
fmt.Println("txHash: ",base58.Encode(txHash))
bytes, err := borsh.Serialize(*signedTx)
if err != nil {
	panic(err)
}
encodeTx := base64.StdEncoding.EncodeToString(bytes)

hash, err := client.SubmitTx(encodeTx)
if err != nil {
	panic(err)
}
fmt.Println("submit: ",hash)

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant