diff --git a/docs/dev/Integration/guide.md b/docs/dev/Integration/guide.md index 0d86562..3edc118 100644 --- a/docs/dev/Integration/guide.md +++ b/docs/dev/Integration/guide.md @@ -158,6 +158,7 @@ For exchanges, restrict withdrawals to P2PK addresses and invalidate other types [ergo-simple-addresses](https://github.com/kushti/ergo-simple-addresses) contains Java-friendly utils for working with addresses. + ### Composing Transactions Outside the Node Get unspent UTXOs for an address using the `transactions/boxes/byAddress/unspent` Explorer API method: @@ -166,6 +167,18 @@ Get unspent UTXOs for an address using the `transactions/boxes/byAddress/unspent https://api.ergoplatform.com/transactions/boxes/byAddress/unspent/9gAE5e454UT5s3NB1625u1LynQYPS2XzzBEK4xumvSZdqnXT35M ``` +When selecting UTXOs manually, be sure to use the binary-encoded version of the inputs. You can retrieve the binary data for a UTXO by making a call to `/utxo/byIdBinary/{boxId}`. + +For example: + +```bash +curl -X 'GET' \ + 'http://127.0.0.1:9053/utxo/byIdBinary/{boxId}' \ + -H 'accept: application/json' +``` + +Use the returned `bytes` field in your `inputsRaw` field of the transaction request. + #### Handling Unconfirmed UTXOs To avoid double-spending, it's important to handle unconfirmed UTXOs properly. There are two main approaches: @@ -197,11 +210,35 @@ Processing user withdrawals in batches by gathering them in a script and pushing This approach can help optimize transaction processing and reduce overall fees. However, it may require adjustments to your existing code framework. +#### Example Batch Transaction Request + +When manually creating transactions, make sure the `inputsRaw` field contains binary-encoded UTXOs retrieved as described earlier. An example transaction might look like this: + +```json +{ + "requests": [ + { + "address": "9ek75mvKwhM5uTT39L9mEdsPGWtMkc7wKRUToVNYT5FSAHJazWc", + "value": 4664620000 + }, + { + "address": "9fF8dd6XcbAx6n475CZqu7JsxSXTLRJm2ov22GiV6kaxrugX1x6", + "value": 1000000000 + } + ], + "fee": 1000000, + "inputsRaw": ["8089938d150008cd021d9e5e6e45f12c5dc22f7edbb78391c51483aef82300f0a4a3eaf2c6c66dfb0ffba5500000f97ba6d3d40d54cd2cabb69baf9fea0e2e23e263b9e0c17c360fc935167aa5fa01"], + "dataInputsRaw": [] +} +``` + +Submit this transaction via a POST request as described below. + ### Broadcasting Transactions To broadcast a transaction made outside the node, serialize it into `JSON`. In Java: -```Java +```java Json json = JsonCodecsWrapper.ergoLikeTransactionEncoder().apply(tx); System.out.println(json.toString()); ``` @@ -209,10 +246,21 @@ System.out.println(json.toString()); Send this `JSON` via a POST request to the public Explorer: ```bash -https://api.ergoplatform.com/api/v0/transactions/send* +curl -X POST "https://api.ergoplatform.com/api/v0/transactions/send" \ +-H "Content-Type: application/json" \ +-d '{...}' ``` -Or to your private Explorer or a node with open API (`POST` to `http://{node_ip}:9053/transactions`) +Or to your private Explorer or a node with open API (`POST` to `http://{node_ip}:9053/transactions`): + +```bash +curl -X POST "http://{node_ip}:9053/transactions" \ +-H "Content-Type: application/json" \ +-d '{...}' +``` + +This ensures that the transaction is properly submitted to the Ergo network for confirmation. + ## Troubleshooting diff --git a/docs/uses/sigmausd.md b/docs/uses/sigmausd.md index 88efe83..e8128ba 100644 --- a/docs/uses/sigmausd.md +++ b/docs/uses/sigmausd.md @@ -1,4 +1,4 @@ -# SigmaUSD +# Accessing Sigmausd As A Developer SigmaUSD is the first eUTxO-based stablecoin, implementing the [AgeUSD protocol](https://github.com/Emurgo/age-usd). It was co-designed by IOHK, Ergo, and Emurgo, focusing on conservative collateral reserve settings, thus eliminating the need for liquidations. SigmaUSD supports a fully decentralized stablecoin emission setup, offering a stable, simple, and decentralized stablecoin.