Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/paritytech/txwrapper
Helper funtions for offline transaction generation.
https://github.com/paritytech/txwrapper
offline polkadot tx
Last synced: about 1 month ago
JSON representation
Helper funtions for offline transaction generation.
- Host: GitHub
- URL: https://github.com/paritytech/txwrapper
- Owner: paritytech
- License: apache-2.0
- Archived: true
- Created: 2019-11-28T15:53:49.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-09-29T09:06:04.000Z (about 3 years ago)
- Last Synced: 2024-10-27T14:09:54.925Z (about 2 months ago)
- Topics: offline, polkadot, tx
- Language: TypeScript
- Homepage:
- Size: 3.59 MB
- Stars: 58
- Watchers: 6
- Forks: 27
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-substrate - TxWrapper - Helpful library for offline transaction creation. (Tools)
- awesome-substrate - TxWrapper - Helpful library for offline transaction creation. (Tools)
README
@substrate/txwrapper
Helper funtions for offline transaction generation.
## DEPRECATION NOTICE
On 9 June 2021 this repo will stop being supported.
Please use [`txwrapper-polkadot`](https://github.com/paritytech/txwrapper-core/tree/main/packages/txwrapper-polkadot) instead of this package for long term support and more features. This package will be phased out in the future in favor of the packages in [`txwrapper-core`](https://github.com/paritytech/txwrapper-core/).
If you are a chain builder looking to build a chain specific `txwrapper` please take a look at [`txwrapper-core`](https://github.com/paritytech/txwrapper-core) and the [guide for chain builders](https://github.com/paritytech/txwrapper-core/blob/main/CHAIN_BUILDER.md).
## Get Started
```bash
yarn add @substrate/txwrapper
```In a JS/TS file:
```typescript
import {
createSignedTx,
createSigningPayload,
methods,
} from '@substrate/txwrapper';const unsigned = methods.balance.transfer(
{
dest: 'FoQJpPyadYccjavVdTWxpxU7rUEaYhfLCPwXgkfD6Zat9QP',
value: 100,
},
{
// Additional information needed to construct the transaction offline.
}
);const signingPayload = createSigningPayload(unsigned, { registry });
// On your offline device, sign the payload.
const signature = myOfflineSigning(signingPayload);// `tx` is ready to be broadcasted.
const tx = createSignedTx(unsigned, signature, { metadataRpc, registry });
```Have a look at the [examples](https://github.com/paritytech/txwrapper/tree/master/examples) to see how you can perform the whole lifecycle of a transaction, from generation to signing to broadcast.
Go to [documentation](https://github.com/paritytech/txwrapper/tree/master/docs/globals.md) to see all available functions.
## Contribute
We welcome contributions. Before submitting your PR, make sure to run the following commands:
- `yarn docs`: Will generate docs based on code comments.
- `yarn test`: Make sure all tests pass.
- `yarn lint`: Make sure your code follows our linting rules. You can also run `yarn lint --fix` to automatically fix some of those errors.### Note for Maintainers
All the commits in this repo follow the [Conventional Commits spec](https://www.conventionalcommits.org/en/v1.0.0/#summary). When merging a PR, make sure 1/ to
use squash merge and 2/ that the title of the PR follows the Conventional Commits spec.The history of commits will be used to generate the `CHANGELOG`. To do so, run `yarn deploy` on the master
branch. This command will look at all the commits since the latest tag, bump the package version according
to semver rules, and generate a new `CHANGELOG`.If you don't want to follow semver or need to do a dry run, consult the [`standard-version` CLI usage](https://github.com/conventional-changelog/standard-version#cli-usag)
docs. Flags for `standard-version` can be passed to `yarn deploy`.`yarn deploy`, which only does local operations and doesn't push anything, will output more or
less the following lines:```bash
$ yarn deploy
yarn run v1.21.1
$ yarn build && standard-version -r minor
$ rimraf lib/ && tsc
✔ bumping version in package.json from 0.3.2 to 0.4.0
✔ outputting changes to CHANGELOG.md
✔ committing package.json and CHANGELOG.md
✔ tagging release v0.4.0
ℹ Run `git push --follow-tags origin master && npm publish` to publish
```To publish the new package, run: `git push --follow-tags origin master && npm publish.`
You must have access to the @substrate organization on npm to publish.### Roadmap
- API revamp to clarify handling of `registry` and `metadataRpc`.
#### Parachain support
- Factor out utility functions and types (such as `decode`, `getRegistry`, `createMethod` etc) into a library for parachain
teams that allows them to release and maintain txwrapper libraries specific to their parachains. This could be called
`@substrate/txwrapper-core`. This lib will allow a parachain team to set up an offline signing lib with unit tests
quickly and painlessly while allowing users access to a consistent `txwrapper` API across parachains.
- While the core utility will be factored out to its own dependency, dispatchables from generic substrate methods
will be published in a package `@substrate/txwrapper-substrate` and Polkadot/Kusama specific dispatchables will be available in
`@substrate/txwrapper-polkadot`. (This could be in a mono repo, but separate packages.) Parachains then create
their own txwrapper lib using the `txwrapper-core` and publish it as `@{parachain-name}/txwrapper`.