This project is a simple example of how to use the GemWallet API to make XRP and USD payments, and add a trustline.
- Clone the repository:
git clone https://github.com/GemWallet/project-starter.git- Serve the index.html in your browser.
To serve the index.html in your browser, you can do the following steps:
- Make sure that you are in this directory
npm installnpm start
The page contains three buttons that trigger the following actions:
- Pay XRP: Sends 20 XRP to the specified destination address.
- Pay USD: Sends 20 USD to the specified issuer address.
- Add trustline: Adds a trustline for USD with the specified issuer.
The result of each action is displayed in the corresponding section of the page, showing the transaction ID.
This project uses version 2.1.0 of the GemWallet API. The API is included in the section of the HTML file using a script tag:
<script src="https://unpkg.com/@gemwallet/api@2.1.0/umd/gemwallet-api.js"></script>The JavaScript code that interacts with the API is included at the end of the HTML file, inside a <script> tag.
Each button has an onclick attribute that triggers a function that makes use of the GemWallet API.
The functions first check if the GemWallet API is connected, and if it is, proceed with the payment or trustline transaction.
The result of the transaction is displayed in the corresponding section of the page by modifying the content of a <strong> tag with an id attribute.
Contributions are welcome! If you have any suggestions or improvements, please feel free to submit a pull request.
This project is licensed under the Apache License.