Comments (4)
Hey @yagop ,
Can you provide more information? Maybe add an example of what you want to achieve?
from mx-sdk-js-core.
Hey @schimih sure, Imagine we have the tx hash (and the signature) but we need the Transaction object to be able to broadcast the tx.
import {
Account,
Address,
TokenPayment,
Transaction,
TransactionVersion,
} from '@multiversx/sdk-core'
import { UserSecretKey, UserSigner } from '@multiversx/sdk-wallet'
const account = new Account(new Address(...));
const signer = new UserSigner(UserSecretKey.fromPem(...));
const tx = new Transaction({
// ...
});
const serializedTransaction = tx.serializeForSigning();
const signature = await signer.sign(serializedTransaction);
// In other part of the code
function broadcastTx(txhash: string, signature: string) {
}
The sendTransaction(tx: ITransaction) method requires a ITransaction
interface.
from mx-sdk-js-core.
Bump 😅
from mx-sdk-js-core.
Hello @yagop,
The transaction hash
is a 32-byte sequence. Signature
is a 64-byte sequence. Neither can be used to recover the transaction object (theoretically & practically impossible).
Perhaps there's the confusion that txHash
and signature
are serialized representations of a transaction? They are not. They are artifacts obtained through content hashing / computing digital signatures.
Simply use the same tx
object to broadcast the transaction:
// Your code
const tx = new Transaction({
// ...
});
const serializedTransaction = tx.serializeForSigning();
const signature = await signer.sign(serializedTransaction);
// New code
tx.applySignature(signature);
await networkProvider.sendTransaction(tx);
tx
(as a Transaction
) follows the ITransaction
interface (they are compatible).
Also, make sure to have a look on the Cookbook:
https://docs.multiversx.com/sdk-and-tools/sdk-js/sdk-js-cookbook/
from mx-sdk-js-core.
Related Issues (20)
- Proposal: re-consider required arguments for Transaction constructor HOT 1
- Adjust / improve ResultsParser to properly handle outcome of relayed transactions HOT 2
- Upgrade breaks Interaction serialization with native variadic arguments HOT 3
- Have "enum.valueOf()" return "fields" as an object (not as an array)
- Add support for `counted-variadic` type in ABI parsing HOT 1
- Setup eslint on sdk-js-* HOT 2
- Setup release.yml on sdk-js-* and sdk-py-* HOT 1
- By default, use TRANSACTION_VERSION_DEFAULT = 2 HOT 1
- On SmartContract.computeAddress(), do extra validation
- Rewrite "TypeExpressionParser" HOT 3
- When building a "relayedV2" transaction, make sure to inherit the version from the inner transaction (both JS and PY) HOT 2
- Use BigInt instead of BigNumber HOT 1
- SignableMessage: one does not simply decode a payload that was previously created using "toJSON()" HOT 1
- Send NFT Functionality Not Working in MultiversX SDK-Core HOT 2
- Migration support: "v12" to "v13" (April 2024) HOT 14
- TokenOperationsOutcomeParser: error when a transaction has multiple events HOT 3
- [v13] Problem with `checkArgumentsCardinality` HOT 9
- Missing `upgradeConstructor` in AbiRegistry HOT 3
- Problem with smart contracts ESDTTransfer in sdk-core 13.0.0-beta.9 and newer HOT 7
- When generating *.d.ts files, skip (ignore) private members
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mx-sdk-js-core.