question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RAW signing via fireblocks API

See original GitHub issue

Hello, I’m trying to sign a delegate transaction via the fireblocks RAW signing API.

Their method takes the transaction serialized in hexadecimal.

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.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
webmaster128commented, Sep 5, 2022

Nice!

And congratz to ourself for designing this great interface 😄

0reactions
nooxxcommented, Sep 5, 2022

Yeah I did, we are keeping our repo private for the moment unfortunately.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Introduction – Fireblocks API Reference
You can submit transfers via the API and receive real-time insights on transfers; sign all transaction types and messages securely with Raw Signing; ......
Read more >
Fireblocks API - Blockdata
You can submit transfers via the API and receive real-time insights on transfers; sign all transaction types and messages securely with Raw Transaction ......
Read more >
How to Easily Stake Polkadot DOT via Fireblocks - Blockdaemon
It's easy to stake your DOT tokens to Blockdaemon using Fireblocks. ... allows you to stake DOT via the Fireblocks system using the...
Read more >
Fireblocks API - Developer docs, APIs, SDKs, and auth.
Fireblocks API specs, API docs, OpenAPI support, SDKs, GraphQL, developer docs, CLI, IDE plugins, API pricing, developer experience, authentication, ...
Read more >
lib.rs - source - Docs.rs
Note: Using FireblocksSigner as a signer WILL NOT take advantage of Fireblock's contextual /// policy engine and will only use the RAW signing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found