RAW signing on theta tesnet (ATOM)
Closed this issue · 0 comments
nooxx commented
Hello, I'm trying to sign a delegate transaction on theta network via the fireblocks RAW signing API.
Here is my code on how to build the transaction:
import { FireblocksSDK, PeerType, TransactionOperation } from 'fireblocks-sdk';
import { coin } from "@cosmjs/proto-signing";
import { MsgDelegate } from "cosmjs-types/cosmos/staking/v1beta1/tx";
import { toHex } from "@cosmjs/encoding";
import { makeSignDoc, serializeSignDoc } from "@cosmjs/amino";
const fs = require('fs');
const apiSecret = fs.readFileSync('./fireblocks_secret.key', 'utf8');
const apiKey = 'xxx';
const fireblocks = new FireblocksSDK(apiSecret, apiKey);
(async () => {
const vault = await fireblocks.getVaultAccountsWithPageInfo({
namePrefix: 'account name',
});
const vaultId = vault.accounts[0].id;
try {
const msg = MsgDelegate.fromPartial({
delegatorAddress: 'cosmos19c9fdh488vqjclltwp68jm50ydwyh36jqeatev',
validatorAddress: 'cosmosvaloper178h4s6at5v9cd8m9n7ew3hg7k9eh0s6wptxpcn',
amount: coin('5000', "uatom"),
});
const memo = "Use your power wisely";
const feeAmount = coin(5193, "uatom");
const sendMsg = {
type: "/cosmos.staking.v1beta1.MsgDelegate",
value: msg,
};
const fee = {
amount: [feeAmount],
gas: '300000',
};
const accountNumber = 698081;
const sequence = 0;
const doc = makeSignDoc(
[sendMsg],
fee,
'theta-testnet-001',
memo,
accountNumber,
sequence,
);
const encoded = toHex(serializeSignDoc(doc));
const res = await fireblocks.createTransaction({
assetId: 'ATOM_COS_TEST',
note: 'Automated ATOM staking transaction',
source: {
type: PeerType.VAULT_ACCOUNT,
id: vaultId,
},
operation: TransactionOperation.RAW,
extraParameters: {
rawMessageData: {
messages: [
{
content: encoded,
},
],
},
},
});
console.log('success:', res);
} catch (err) {
console.log(err);
}
})();
Do you see any issue with this code? When submitting this, the transaction is "submitted" for signing but marked as "failed" in fireblocks.