Hedera
Search…
Manually sign a transaction
Sign a transaction using the private key(s) required to sign the transaction. You cannot sign the transaction with a public key. If your client operator account private key is the key used in the key field(s) of a transaction, you do not need to manually sign the transaction. The execute(client) method signs the transaction with the client operator account private key before it is submitted to a Hedera network.
V2
V1
Method
Type
Description
sign(<privateKey>)
PrivateKey
Sign the transaction with an Ed25519 private key
signWith(<publicKey, transactionSigner>)
PublicKey, TransactionSigner
Sign the transaction with a callback that may block waiting for user confirmation.
signWithOperator(<client>)
Client
Sign the transaction with the client
Java
1
//Create any transaction
2
AccountUpdateTransaction transaction = new AccountUpdateTransaction()
3
.setAccountId(accountId)
4
.setKey(key);
5
6
//Freeze the transaction for signing
7
AccountUpdateTransaction freezeTransaction = transaction.freezeWith(client);
8
9
//Sign the transaction with a private key
10
AccountCreateTransaction signedTransaction = freezeTransaction
11
.sign(PrivateKey.fromString("302e020100300506032b65700422042012a4a4add3d885bd61d7ce5cff88c5ef2d510651add00a7f64cb90de3359bc5c");
12
13
//v2.0.0
Copied!
JavaScript
1
//Create any transaction
2
const transaction = await new AccountUpdateTransaction()
3
.setAccountId(accountId)
4
.setKey(key)
5
.freezeWith(client);
6
7
//Sign the transaction with a private key
8
const signedTransaction = transaction
9
.sign(PrivateKey.fromString("302e020100300506032b65700422042012a4a4add3d885bd61d7ce5cff88c5ef2d510651add00a7f64cb90de3359bc5c");
Copied!
Go
1
//Create any transaction
2
transaction := hedera.NewAccountUpdateTransaction().
3
SetAccountID(newAccountId).
4
SetKey(updateKey.PublicKey())
5
6
//Freeze the transaction for signing
7
freezeTransaction, err := transaction.FreezeWith(client)
8
if err != nil {
9
panic(err)
10
}
11
12
signedTransaction := freezeTransaction.Sign(hedera.PrivateKeyFromString("302e020100300506032b65700422042012a4a4add3d885bd61d7ce5cff88c5ef2d510651add00a7f64cb90de3359bc5c"))
13
//v2.0.0
Copied!
Method
Type
Description
sign(<privateKey>)
Ed25519PrivateKey
Sign the transaction with an Ed25519 private key
Java
1
//Create any transaction
2
AccountUpdateTransaction transaction = new AccountUpdateTransaction()
3
.setAccountId(accountId)
4
.setKey(publicKey);
5
6
//Freeze the transaction for signing
7
Transaction freezeTransaction = transaction.build(client);
8
9
//Sign the transaction with a private key
10
AccountCreateTransaction signedTransaction = freezeTransaction
11
.sign(Ed25519PrivateKey.fromString("302e020100300506032b65700422042012a4a4add3d885bd61d7ce5cff88c5ef2d510651add00a7f64cb90de3359bc5c");
12
13
//v1.3.2
Copied!
JavaScript
1
//Create any transaction
2
const transaction = new AccountUpdateTransaction()
3
.setAccountId(accountId)
4
.setKey(publicKey);
5
6
//Freeze the transaction for signing
7
const freezeTransaction = transaction.build(client);
8
9
//Sign the transaction with a private key
10
const signedTransaction = freezeTransaction
11
.sign(Ed25519PrivateKey.fromString("302e020100300506032b65700422042012a4a4add3d885bd61d7ce5cff88c5ef2d510651add00a7f64cb90de3359bc5c");
12
13
//v1.4.4
Copied!

Last modified 6d ago
Copy link
Contents