-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathjmemo.html
More file actions
150 lines (139 loc) · 3.77 KB
/
Copy pathjmemo.html
File metadata and controls
150 lines (139 loc) · 3.77 KB
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
---
layout: default
title: JMemo
permalink: /jmemo/
section: jmemo
---
<h1 class="page-header">JMemo</h1>
<ul>
<li>
<a href="#jmemo-getting-started">Getting Started</a>
</li>
<li>
<a href="#jmemo-generate-key">Generate Private Key</a>
</li>
<li>
<a href="#jmemo-api-token">Get API Token</a>
</li>
<li>
<a href="#jmemo-api-fund-address">Get API Fund Address</a>
</li>
<li>
<a href="#jmemo-create-post">Create Post</a>
</li>
<li>
<a href="#jmemo-use-bsv">Use BSV</a>
</li>
</ul>
<br>
<a class="anchor" id="jmemo-getting-started"></a>
<h2>
Getting Started
<a class="anchor-link" href="#jmemo-getting-started">
<span class="glyphicon glyphicon-link"></span>
</a>
</h2>
<ol>
<li>
Load <code>jmemo.min.js</code>
<pre><code class="language-html"><script src="jmemo.min.js"></script></code></pre>
</li>
</ol>
<br>
<a class="anchor" id="jmemo-generate-key"></a>
<h2>
Generate Private Key
<a class="anchor-link" href="#jmemo-generate-key">
<span class="glyphicon glyphicon-link"></span>
</a>
</h2>
<ol>
<li>
Generate mnemonic
<pre><code class="language-javascript">var mnemonic = jmemo.Wallet.GenerateMnemonic();</code></pre>
</li>
<li>
Get child key and address
<pre><code class="language-javascript">var child = jmemo.Wallet.GetHDChild(mnemonic, jmemo.Wallet.Path.MainAddressPath());
var address = jmemo.Wallet.GetAddress(child.publicKey).address;</code></pre>
</li>
</ol>
<br>
<a class="anchor" id="jmemo-api-token"></a>
<h2>
Get API Token
<a class="anchor-link" href="#jmemo-api-token">
<span class="glyphicon glyphicon-link"></span>
</a>
</h2>
<ol>
<li>
<pre><code class="language-javascript">var key;
jmemo.Client.Api.Key.New(function(response) {
key = response;
});</code></pre>
</li>
</ol>
<br>
<a class="anchor" id="jmemo-api-fund-address"></a>
<h2>
Get API Fund Address
<a class="anchor-link" href="#jmemo-api-fund-address">
<span class="glyphicon glyphicon-link"></span>
</a>
</h2>
<ol>
<li>
<pre><code class="language-javascript">var fundAddress;
jmemo.Client.Basic.BalanceWithToken(address, key.token, key.secret, function(response) {
fundAddress = response.api_address;
});</code></pre>
</li>
<li>
Send funds to generated address and API fund address,
5,000-10,000 satoshis each is plenty
</li>
</ol>
<br>
<a class="anchor" id="jmemo-create-post"></a>
<h2>
Create Post
<a class="anchor-link" href="#jmemo-create-post">
<span class="glyphicon glyphicon-link"></span>
</a>
</h2>
<ol>
<li>
Create unsigned transaction (requires API and address have enough funds)
<pre><code class="language-javascript">var unsignedTx;
jmemo.Client.Create.Post(key.token, key.secret, address, "Example", function(tx) {
unsignedTx = tx;
});</code></pre>
</li>
<li>
Sign transaction
<pre><code class="language-javascript">var signedTx = jmemo.Wallet.Sign.SignTx(unsignedTx.raw, child);</code></pre>
</li>
<li>
Broadcast transaction
<pre><code class="language-javascript">jmemo.Client.Tx.Broadcast(signedTx.raw);</code></pre>
</li>
<li>
View transaction
<pre><code class="language-javascript">location.href = "https://memo.cash/explore/tx/" + signedTx.hash;</code></pre>
</li>
</ol>
<br>
<a class="anchor" id="jmemo-use-bsv"></a>
<h2>
Use BSV
<a class="anchor-link" href="#jmemo-use-bsv">
<span class="glyphicon glyphicon-link"></span>
</a>
</h2>
<ol>
<li>
Set host name
<pre><code class="language-javascript">jmemo.Client.SetHost("https://v1.api.memo.sv");</code></pre>
</li>
</ol>