Поток, которым я должен следить,: < /p>
Создать транзакцию < /p>
< /li>
сериализуйте транзакцию в байты транзакции < /p>
< /li>
HSM для подписания < /p>
< /li>
Deserialize Bytes Transaction Bytes обратно в транзакцию < /p>
< /li>
Подписанная транзакция в сеть < /p>
< /li>
< /ol>
. Invalid_signature Ошибка. Я позаботился о том, чтобы ключ был правильным. < /P>
Код: Выделить всё
const {
Client,
AccountId,
PrivateKey,
TransferTransaction,
Hbar,
Transaction,
} = require("@hashgraph/sdk");
async function main() {
const client = Client.forTestnet();
const operatorPrivateKeyHex =
"0xXXX";
const operatorId = AccountId.fromString("0.0.XXX");
const operatorKey = PrivateKey.fromString(operatorPrivateKeyHex);
client.setOperator(operatorId, operatorPrivateKeyHex);
let transaction = await new TransferTransaction()
.addHbarTransfer(operatorId, Hbar.fromTinybars(-100))
.addHbarTransfer(AccountId.fromString("0.0.3"), Hbar.fromTinybars(100))
.setNodeAccountIds([AccountId.fromString("0.0.5")])
.freezeWith(client);
const txByte = transaction.toBytes();
const signature = operatorKey.sign(txByte);
transaction = Transaction.fromBytes(txByte);
transaction.addSignature(operatorKey.publicKey, signature);
const txResponse = await transaction.execute(client);
const receipt = await txResponse.getReceipt(client);
}
main();Подробнее здесь: https://stackoverflow.com/questions/795 ... script-sdk
Мобильная версия