-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add trx example * up * add `00` in fullsig + switch keccack to sha256 * up * up * up * feat(signTrxTx) update signature + use tx_id from tx-api * up * up url * remove unused import --------- Co-authored-by: Martin Saldinger <[email protected]>
- Loading branch information
1 parent
8b0ae6d
commit 88fdef5
Showing
4 changed files
with
110 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { Kiln, trxToSun } from '../src/kiln'; | ||
import type { FireblocksIntegration } from '../src/fireblocks'; | ||
import fs from 'node:fs'; | ||
import 'dotenv/config'; | ||
|
||
const apiSecret = fs.readFileSync(`${__dirname}/fireblocks_secret_prod.key`, 'utf8'); | ||
|
||
const k = new Kiln({ | ||
baseUrl: process.env.KILN_API_URL as string, | ||
apiToken: process.env.KILN_API_KEY, | ||
}); | ||
|
||
const vault: FireblocksIntegration = { | ||
provider: 'fireblocks', | ||
fireblocksApiKey: process.env.FIREBLOCKS_API_KEY as string, | ||
fireblocksSecretKey: apiSecret, | ||
vaultId: 17, | ||
}; | ||
|
||
try { | ||
console.log('crafting...'); | ||
const tx = await k.client.POST('/trx/transaction/stake', { | ||
body: { | ||
account_id: '', | ||
owner_address: 'TAERHY5gyzDRmAaeqqa6C4Fuyc9HLnnHx7', | ||
amount_sun: trxToSun('1').toString(), | ||
resource: 'BANDWIDTH', | ||
}, | ||
}); | ||
|
||
if (!tx.data) throw new Error('No data in response'); | ||
|
||
console.log('signing...'); | ||
const signResponse = await k.fireblocks.signTrxTx(vault, tx.data.data); | ||
|
||
console.log('broadcasting...'); | ||
const broadcastedTx = await k.client.POST('/trx/transaction/broadcast', { | ||
body: { | ||
signed_tx_serialized: signResponse.signed_tx.data.signed_tx_serialized, | ||
}, | ||
}); | ||
console.log(broadcastedTx); | ||
} catch (err) { | ||
console.log(err); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters