This repository has been archived by the owner on Sep 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
/
setup-wallets-programmatically.html
222 lines (193 loc) Β· 12.7 KB
/
setup-wallets-programmatically.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="The protocol for connecting blockchains and other ledgers">
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<!-- Custom styles -->
<link href="/assets/css/custom.css" rel="stylesheet">
<!-- Google fonts -->
<link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,300,200,600,700,900|Droid+Sans+Mono|Titillium+Web:400,300,600,900' rel='stylesheet' type='text/css'>
<link href="/assets/img/favicon.png" rel="icon" type="image/x-icon">
<!-- highlight js -->
<link rel="stylesheet" href="/assets/css/monokai-sublime.css">
<!-- fontawesome icons -->
<link rel="stylesheet" href="/assets/fontawesome/css/font-awesome.min.css" />
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body class="sidebar-primary ">
<!-- <div class="container"> -->
<nav class="navbar fixed-top navbar-expand-lg navbar-dark nav-innerpage">
<div class="navbar-leftbg"><a href="/" class="navbar-brand"><img src="/assets/img/[email protected]" class="logo" height="44" alt="Interledger" /></a></div>
<button type="button" class="navbar-toggler" data-toggle="collapse" data-target="#navbarHolder" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse justify-content-end" id="navbarHolder">
<ul class="nav navbar-nav">
<li class="nav-item" ><a class="nav-link" href="/overview.html">Docs</a></li>
<li class="nav-item" ><a class="nav-link" href="/libraries.html">Tools</a></li>
<li class="nav-item" ><a class="nav-link" href="/community.html">Community</a></li>
<li class="nav-item"><a class="nav-link" target="_blank" href="https://github.com/interledger">Edit on Github</a></li>
<li class="nav-item"><a class="nav-link cornerlink" href="/overview.html">Get Started</a></li>
</ul><!-- /.navbar-nav -->
<div class="cornerbox"></div>
</div>
<div class="menu-overlay"></div>
</nav>
<!-- </div> -->
<div class="container-fluid" role="document" id="main_content_wrapper">
<div class="row">
<aside class="sidebar col-md-4 col-lg-3 p-0 order-md-1" role="complementary">
<div id="sidenav" class="tree_nav">
<ul class=" sidebar_pagelist">
<li class="nav-label">Getting Started</li>
<ul class=" sidebar_pagelist sidebar_indent">
<li><a href="/overview.html">Overview</a></li>
<li><a href="/setup-wallets.html">Set Up and Use Interledger Accounts</a></li>
<li><a href="/setup-wallets-programmatically.html">Manage Interledger Accounts Programmatically</a></li>
<li><a href="/spin-up-local-network.html">Spin Up a Local ILP Network</a></li>
</ul>
</ul>
<ul class=" sidebar_pagelist">
<li class="nav-label">Community Resources</li>
<li><a class="external-link" href="https://medium.com/interledger-blog">Blog and Tutorials<i class="fa fa-external-link" aria-hidden="true"></i></a></li>
<li><a href="/libraries.html">Libraries and Tools</a></li>
<li><a href="/summit-2019.html">ILP Summit 2019 Videos</a></li>
</ul>
<div class="sidebar-nav-header">Specs</div>
<ul class=" sidebar_pagelist sidebar_indent">
<li><a href="/rfcs/0027-interledger-protocol-4/">Interledger Protocol 4 (ILPv4)</a></li>
<li><a href="/rfcs/0015-ilp-addresses/">Interledger Addresses</a></li>
<li><a href="/rfcs/0029-stream/">STREAM Protocol</a></li>
<li><a href="/rfcs/0009-simple-payment-setup-protocol/">Simple Payment Setup Protocol (SPSP)</a></li>
<li><a href="/rfcs/0030-notes-on-oer-encoding/">Notes on OER encoding</a></li>
<li><a href="/rfcs/0031-dynamic-configuration-protocol/">Dynamic Configuration Protocol (ILDCP)</a></li>
<li><a href="/rfcs/0032-peering-clearing-settlement/">Peering, Clearing and Settlement</a></li>
<li><a href="/rfcs/0038-settlement-engines/">Settlement Engines</a></li>
<li><a href="/rfcs/0035-ilp-over-http/">ILP over HTTP</a></li>
<li><a href="/rfcs/0036-spsp-pull-payments/">SPSP Pull Payments</a></li>
<li> </li>
<li><a class="external-link" target="_blank" href="https://paymentpointers.org">Payment Pointers</a></li>
<li><a class="external-link" target="_blank" href="https://webmonetization.org">Web Monetization</a></li>
<li><a class="external-link" target="_blank" href="https://w3c.github.io/webpayments/proposals/interledger-payment-method.html">W3C Web Payments</a></li>
</ul>
</div> </aside>
<!-- main column -->
<main class="main col-md-8 col-lg-6 order-md-3 " role="main" id="main_content_body">
<article class="pt-3 p-md-3">
<div class="content doc-content">
<h1 id="main-page-header">Manage Interledger Accounts Programmatically</h1>
<p class="blurb">Make payments programmatically on a testnet.</p>
<p><em>Before starting this tutorial, make sure you have created accounts in both the Rafiki and Xpring wallets by following the instructions in the <a class="external-link" href="https://interledger.org/setup-wallets.html" target="_blank">Setup Wallets <i aria-hidden="true" class="fa fa-external-link"></i></a> tutorial.</em></p>
<p>To get started using Interledger, this tutorial helps you access the Interledger testnet programmatically. This Interledger testnet is currently maintained by teams at <a class="external-link" href="https://xpring.io/" target="_blank">Xpring <i aria-hidden="true" class="fa fa-external-link"></i></a> and <a class="external-link" href="https://coil.com/" target="_blank">Coil <i aria-hidden="true" class="fa fa-external-link"></i></a>, but anyone can join. Note that all Interledger test networks use fake money, rather than transferring real value. </p>
<p>The Xpring and Rafiki testnet connectors, both used in this tutorial, together form a network for users to practice sending and receiving test currency values. Although this tutorial uses test XRP for simplicity, Interledger can handle transactions involving any currency pairs, as described in <a href="overview.html">Interledger Overview</a>.</p>
<p>In this tutorial, you will:</p>
<ol>
<li><a href="#1-check-your-balance">Check Your Balance</a>.</li>
<li><a href="#2-pay-a-friend">Pay a Friend</a> to another payment pointer.</li>
<li><a href="#3-get-paid">Get Paid</a>.</li>
</ol>
<h3 id="1-check-your-balance">1. Check Your Balance</h3>
<p>To programmatically see how much money is in your account, use the following <a class="external-link" href="https://curl.haxx.se/docs/manual.html" target="_blank">curl <i aria-hidden="true" class="fa fa-external-link"></i></a> call. Be sure to replace <strong><code>{your-account-id}</code></strong> and <strong><code>{auth_token}</code></strong> above with the values obtained from the xpring.io portal.</p>
<pre><code class="bash">curl --location
--request GET 'https://xpring.io/portal/ilp/hermes/accounts/{your-account-id}/balance' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {auth_token}'
</code></pre>
<p>This request will return a JSON response similar to the following:</p>
<pre><code class="json">{
"assetCode": "XRP",
"assetScale": "9",
"accountBalance": {
"accountId": "caesar",
"netBalance": "1000",
"clearingBalance": "1000",
"prepaidAmount": "1000"
}
}
</code></pre>
<h3 id="2-pay-a-friend">2. Pay a Friend</h3>
<p>You can use your account to send test funds to a different payment pointer. This example uses a destination payment pointer on <a class="external-link" href="https://rafiki.money" target="_blank">https://rafiki.money <i aria-hidden="true" class="fa fa-external-link"></i></a>. Substitute your <code>accountId</code> from Step 1. You can change the destination payment pointer if you prefer.</p>
<pre><code class="bash">curl --location \
--request POST 'https://xpring.io/portal/ilp/hermes/accounts/{your-account-id}/pay' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {auth_token}' \
--data-raw '{
"amount": "1000000",
"destinationPaymentPointer": "$rafiki.money/p/{username}"
}'
</code></pre>
<p>This request returns a JSON response similar to the following:</p>
<pre><code class="json">{
"originalAmount": "1000000",
"amountDelivered": "1000000",
"amountSent": "1000000",
"successfulPayment": true
}
</code></pre>
<ul>
<li><strong><code>originalAmount</code></strong>: The amount that you wanted to send.</li>
<li><strong><code>amountDelivered</code></strong>: The amount received by your friend, specified in the asset and units used by your friend.</li>
<li><strong><code>amountSent</code></strong> The amount you sent to your friend, specified in the asset and units of your account.</li>
</ul>
<h3 id="3-get-paid">3. Get Paid</h3>
<p>Set up a Xpring testnet account and a rafiki.money account so you have two destination pointers to work with. Experiment with sending and receiving payments in both directions. Check your balance to make sure that the money has arrived in your account.</p>
<h3 id="combine-gui-and-programmatic-interactions">Combine GUI and Programmatic Interactions</h3>
<p>If you log in to your accounts at <a class="external-link" href="https://rafiki.money" target="_blank">rafiki.money <i aria-hidden="true" class="fa fa-external-link"></i></a> or <a class="external-link" href="https://xpring.io" target="_blank">https://xpring.io <i aria-hidden="true" class="fa fa-external-link"></i></a>, you can directly see the results of the commands you performed above.</p>
</div>
</article>
</main>
<aside class="right-sidebar col-lg-3 order-lg-4 p-0" role="complementary">
<div class="card" id="page-toc-wrapper">
<div class="card-header">
<h4>On This Page</h4>
</div>
<ul class="card-body">
<li class="level-3"><a href="#1-check-your-balance">1. Check Your Balance</a></li>
<li class="level-3"><a href="#2-pay-a-friend">2. Pay a Friend</a></li>
<li class="level-3"><a href="#3-get-paid">3. Get Paid</a></li>
<li class="level-3"><a href="#combine-gui-and-programmatic-interactions">Combine GUI and Programmatic Interactions</a></li>
</ul>
</div>
</aside>
</div><!--/.row (main layout)-->
</div>
<footer>
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="col-sm-9 col-xs-12 float-left footertext">
<p><img src="/assets/img/[email protected]" height="44" alt="Interledger" align="left" /> Interledger Project<br><span>Documentation licensed under <a href="https://creativecommons.org/licenses/by/4.0/">CC BY 4.0.</a></span></p>
</div>
<div class="col-sm-3 col-xs-12 float-right">
<a href="https://twitter.com/interledger"><img src="/assets/img/Twitter.png"></a>
<a href="https://communityinviter.com/apps/interledger/interledger-working-groups-slack"><img src="/assets/img/Slack.png"></a>
</div>
</div>
</div>
</div>
</footer>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="/assets/js/bootstrap.min.js"></script>
<script src="/assets/js/highlight.pack.js"></script>
<script src="/assets/js/custom.js"></script>
<!-- <script src="/assets/js/home.js"></script> -->
<!-- <script type="text/javascript" src="/assets/js/svg-animation.js"></script> -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-68500608-1', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>