From d9a0408783a0a614ec8b3f4dafc404f88ea4ad95 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Tue, 23 Jul 2024 12:33:12 +0530 Subject: [PATCH] Added functionality to broadcast a signed transaction --- CHANGELOG.md | 3 ++- src/index.js | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 55e08fe..78e434e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,4 +8,5 @@ - Added initial test - Added functionality to sign message - Added get balance method to fetch SOL balance of an account -- Added functionality to sign SOL and fungible tokens transfer transaction \ No newline at end of file +- Added functionality to sign SOL and fungible tokens transfer transaction +- Added functionality to broadcast a signed transaction \ No newline at end of file diff --git a/src/index.js b/src/index.js index 558b5b0..332148c 100644 --- a/src/index.js +++ b/src/index.js @@ -100,6 +100,22 @@ class KeyringController { } } + async sendTransaction(rawTransaction) { + + try { + const { network } = this.store.getState() + const stringBuff = Buffer.from(rawTransaction, 'hex') + + const connection = new solanaWeb3.Connection(network, "confirmed") + const transactionDetails = await connection.sendRawTransaction(stringBuff) + return { transactionDetails: transactionDetails } + + } catch (err) { + console.log(err); + throw err + } + } + persistAllAddress(_address) { const { address } = this.store.getState(); let newAdd = address;