https://github.com/nirvanush/txbuilder-service
https://github.com/nirvanush/txbuilder-service
Last synced: 6 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/nirvanush/txbuilder-service
- Owner: nirvanush
- Created: 2022-08-05T14:30:45.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-08-15T06:12:05.000Z (over 2 years ago)
- Last Synced: 2023-03-05T16:22:01.759Z (about 2 years ago)
- Language: JavaScript
- Size: 154 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-ergo - TxBuilder Service (nirvanush) - Service for building transactions, potentially off-chain. [`TS`?] *(Community)* (🛠️ Development Tooling <a id="development-tooling"></a> / 🔌 Node Interaction & APIs <a id="node-interaction--apis"></a>)
README
# Lite weight nodejs service to build transaction
Can run on aws serverless lambda or on a server with `npm run dev`;
I suggest trying lambda because it's free.### Based on:
- [ergoscript.js](https://github.com/nirvanush/ergoscript) - transaction builder library
- [isomorphic-wallet](https://github.com/nirvanush/isomorphic-wallet) - in code wallet with same api as dapp connector.## How to start
```
git clone https://github.com/nirvanush/txbuilder-service
cd txbuilder-service
npm i
npm run startWill run on port 5008
```## How to use:
Use the tx configuration syntax as described it [ergoscript.js](https://github.com/nirvanush/ergoscript) README.md;Here is the example of generating a simple transaction of sending 5 Comet:
```
const response = await fetch('yourhost.com/build_tx', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
"config": [{
"funds": {
"ERG": 10000000,
"tokens": [{
"tokenId": "0cd8c9f416e5b1ca9f986a7f10a84191dfb85941619e49e53c0dc30ebf83324b",
"amount": 5
}]
},
"toAddress": "",
"additionalRegisters": {
value: '40', type: 'Int'
}
}],
"userAddress": await ergo.get_change_address() // this is the public address of user that will have to sign this tx later.
})
}).then(resp => resp.json());const { unsignedTx } = response;
// later you can sign this tx using dapp connector
// and submit
const signedTx = ergo.sign_tx(unsignedTx)
const hash = ergo.submit_tx(signedTx);
```### TODO:
- Custom explorer endpoint, currently using public.