|
1 | | -# Simplicity Web IDE Guide |
2 | | - |
3 | | -## What is the Web IDE? |
| 1 | +# How to make a transaction using the web IDE |
4 | 2 |
|
5 | 3 | The Simplicity Web IDE is a browser-based development environment for writing, compiling, and deploying Simplicity contracts to Liquid testnet. |
6 | 4 |
|
7 | | -**Repository:** https://github.com/BlockstreamResearch/simplicity-webide |
8 | | -**Live Demo:** (Deploy locally or access hosted instance) |
| 5 | +Repository: https://github.com/BlockstreamResearch/simplicity-webide |
| 6 | +Live Demo: (Deploy locally or https://ide.simplicity-lang.org) |
9 | 7 |
|
10 | 8 | **Features:** |
11 | 9 | - Write SimplicityHL contracts in browser |
12 | 10 | - Compile to Simplicity bytecode |
13 | 11 | - Generate P2TR addresses |
14 | 12 | - Build transactions |
15 | 13 | - Deploy to Liquid testnet |
16 | | -- No installation required |
17 | | - |
18 | | ---- |
19 | | - |
20 | | -## Interface Overview |
21 | | - |
22 | | - |
23 | | - |
24 | | -**Components:** |
25 | | - |
26 | | -1. **Code Editor** (Left panel) |
27 | | - - Syntax highlighting for SimplicityHL |
28 | | - - Line numbers |
29 | | - - Error highlighting |
30 | | - |
31 | | -2. **Compiler Output** (Right panel) |
32 | | - - Compilation status |
33 | | - - CMR display |
34 | | - - P2TR address |
35 | | - - Error messages |
36 | | - |
37 | | -3. **Transaction Builder** (Bottom panel) |
38 | | - - Input UTXO details |
39 | | - - Output configuration |
40 | | - - Witness data entry |
41 | | - - Build & broadcast buttons |
42 | 14 |
|
43 | | -4. **Network Selector** (Top bar) |
44 | | - - Liquid Testnet (default) |
45 | | - - Settings and options |
| 15 | +The SimplicityHL web IDE can only make a restricted form of transaction: There is 1 transaction input, 1 transaction output and 1 fee output _(Liquid has explicit fee outputs)_. Confidential transactions or assets other than Bitcoin are not supported. |
46 | 16 |
|
47 | | ---- |
| 17 | + |
48 | 18 |
|
49 | | -## Getting Started |
| 19 | +## Write the main function |
50 | 20 |
|
51 | | -### Step 1: Open the Web IDE |
| 21 | +Open [the SimplicityHL web IDE](https://ide.simplicity-lang.org/) and write the main function of your program. |
52 | 22 |
|
53 | | -Navigate to the Web IDE deployment in your browser. |
| 23 | +_You can leave the default main function as it is. Customize it if you want._ |
54 | 24 |
|
55 | | - |
| 25 | + |
56 | 26 |
|
57 | | -### Step 2: Write Your Contract |
| 27 | +## Generate an address |
58 | 28 |
|
59 | | -**Example - Simple Contract:** |
| 29 | +Click the "Address" button to copy the address of your program to the clipboard. |
60 | 30 |
|
61 | | -```rust |
62 | | -fn main() { |
63 | | - // This contract always succeeds |
64 | | -} |
65 | | -``` |
| 31 | +Leave the web IDE tab open. You will need it later. |
66 | 32 |
|
67 | | -Click **Compile** button. |
| 33 | + |
68 | 34 |
|
69 | | - |
| 35 | +## Fund the address |
70 | 36 |
|
71 | | -**Output shows:** |
72 | | -- CMR (Commitment Merkle Root) |
73 | | -- P2TR address |
74 | | -- Compilation success/errors |
| 37 | +Paste the address into [the Liquid testnet faucet](https://liquidtestnet.com/faucet) and press the "Send assets" button. |
75 | 38 |
|
76 | | -### Step 3: Generate Address |
| 39 | + |
77 | 40 |
|
78 | | -After compilation, the IDE displays the P2TR address and CMR. |
| 41 | +Copy the ID of the funding transaction to your clipboard. |
79 | 42 |
|
80 | | - |
| 43 | + |
81 | 44 |
|
82 | | -**What this means:** |
83 | | -- P2TR address: Where to send funds |
84 | | -- CMR: Unique identifier for this contract |
| 45 | +## Look up the funding transaction |
85 | 46 |
|
86 | | -Copy the P2TR address. |
| 47 | +Paste the ID of the funding transaction into the [Blockstream Explorer for Liquid testnet](https://blockstream.info/liquidtestnet/). |
87 | 48 |
|
88 | | -### Step 4: Fund the Address |
| 49 | + |
89 | 50 |
|
90 | | -**Option A: Use Faucet Website** |
| 51 | +Scroll down and find the SimplicityHL UTXO. The Liquid testnet faucet always sends 100000 tL-BTC. In our example, the SimplicityHL UTXO is vout = 1. |
91 | 52 |
|
92 | | -Navigate to: https://liquidtestnet.com/faucet |
| 53 | + |
93 | 54 |
|
94 | | - |
| 55 | +## Enter UTXO data into the web IDE |
95 | 56 |
|
96 | | -Paste your P2TR address and request L-BTC. |
| 57 | +Enter the ID of the funding transaction and the vout into the web IDE. |
97 | 58 |
|
98 | | - |
| 59 | +_You can leave the remaining fields as they are. Feel free to customize._ |
99 | 60 |
|
100 | | -**Option B: Via API** |
101 | | -```bash |
102 | | -curl "https://liquidtestnet.com/faucet?address=tex1p...&action=lbtc" |
103 | | -``` |
| 61 | + |
104 | 62 |
|
105 | | -Wait 60 seconds for confirmation. |
| 63 | +## Sign the spending transaction |
106 | 64 |
|
107 | | -### Step 5: Check Balance |
| 65 | +Click the "Sig 0" button to generate a signature for a transaction that spends the SimplicityHL UTXO. |
108 | 66 |
|
109 | | -Use the Blockstream explorer to verify: https://blockstream.info/liquidtestnet |
| 67 | + |
110 | 68 |
|
111 | | - |
| 69 | +Paste the signature into the `mod witness {...}` section. |
112 | 70 |
|
113 | | -**Or via API:** |
114 | | -```bash |
115 | | -curl "https://blockstream.info/liquidtestnet/api/address/tex1p.../utxo" |
116 | | -``` |
| 71 | + |
117 | 72 |
|
118 | | -**Response shows:** |
119 | | -```json |
120 | | -[{ |
121 | | - "txid": "abc123...", |
122 | | - "vout": 0, |
123 | | - "value": 100000 |
124 | | -}] |
125 | | -``` |
| 73 | +## Generate the spending transaction |
126 | 74 |
|
127 | | -Note the `txid` and `vout` - you'll need these for the transaction builder. |
| 75 | +Click the "Transaction" button to copy the spending transaction to your clipboard. |
128 | 76 |
|
129 | | -### Step 6: Enter Transaction Details |
| 77 | + |
130 | 78 |
|
131 | | -Scroll to the **Transaction** section in the Web IDE. |
| 79 | +## Broadcast the spending transaction |
132 | 80 |
|
133 | | - |
| 81 | +Paste the spending transaction into the [Blockstream Liquid testnet explorer](https://blockstream.info/liquidtestnet/tx/push) and click the "Broadcast transaction" button. |
134 | 82 |
|
135 | | -**Enter UTXO data from Step 5:** |
136 | | -1. **Txid:** Paste the funding transaction ID |
137 | | -2. **Vout:** Enter output index (usually `0` or `1`) |
138 | | -3. **Value:** Enter amount in sats (e.g., `100000`) |
| 83 | + |
139 | 84 |
|
140 | | -Leave destination and other fields as defaults for now. |
| 85 | +If everything worked, the explorer will open the broadcast transaction. In this case, congratulations, you made a SimplicityHL transaction on Liquid testnet!!! You can also look up your transaction on [mempool.space](https://liquid.network/testnet). |
141 | 86 |
|
142 | | -### Step 7: Generate Signature (For P2PK Contracts) |
| 87 | +If you see an error message, take a look at the following "Troubleshooting" section. |
143 | 88 |
|
144 | | -**For contracts requiring signatures:** |
| 89 | +## Cryptic error message |
145 | 90 |
|
146 | | -Click the **"Sig 0"** button in the Web IDE. |
| 91 | +Cause. |
147 | 92 |
|
148 | | - |
| 93 | +Action to take. |
149 | 94 |
|
150 | | -**The signature is automatically copied to your clipboard!** |
| 95 | +## "Transaction not found" (Blockstream Explorer) |
151 | 96 |
|
152 | | -**Update your contract code:** |
| 97 | +Fake error. The transaction actually worked :) |
153 | 98 |
|
154 | | -Paste the signature into your witness section: |
155 | | -```rust |
156 | | -mod witness { |
157 | | - const SIGNATURE: Signature = 0xf74b3ca574647f8595624b129324afa2...; |
158 | | -} |
159 | | -``` |
| 99 | +Wait for 1 minute and reload the page. |
160 | 100 |
|
161 | | -**What this does:** The Web IDE computes the sighash and signs it with an internal key. |
| 101 | +## `bad-txns-inputs-missingorspent` |
162 | 102 |
|
163 | | -### Step 8: Build Transaction |
| 103 | +The UTXO doesn't exist. |
164 | 104 |
|
165 | | -Click the **"Transaction"** button. |
| 105 | +Double check the txid. You might have to wait for one minute for the UTXO to be included in the blockchain. |
166 | 106 |
|
167 | | - |
| 107 | +## `bad-txns-in-ne-out, value in != value out` |
168 | 108 |
|
169 | | -**The complete transaction hex is copied to your clipboard.** |
| 109 | +The input value does not equal the output value. |
170 | 110 |
|
171 | | -### Step 9: Broadcast Transaction |
| 111 | +Double-check the UTXO info (vout and value). Check that the fee is lower than the input value. |
172 | 112 |
|
173 | | - |
| 113 | +## `bad-txns-fee-outofrange` |
174 | 114 |
|
175 | | -**Copy the transaction hex**, then broadcast via explorer: |
| 115 | +The fee does not cover the transaction weight. |
176 | 116 |
|
177 | | -**Option A: Blockstream Explorer Broadcast Page** |
| 117 | +Increase the fee. |
178 | 118 |
|
179 | | -Navigate to: https://blockstream.info/liquidtestnet/tx/push |
| 119 | +## `non-final` |
180 | 120 |
|
181 | | -Paste your transaction hex and click broadcast. |
| 121 | +The lock time is higher than the current block height. |
182 | 122 |
|
183 | | -**Option B: Via curl:** |
184 | | -```bash |
185 | | -curl -X POST "https://blockstream.info/liquidtestnet/api/tx" -d "020000..." |
186 | | -``` |
| 123 | +Decrease the locktime or wait until the block height is high enough. |
187 | 124 |
|
188 | | -Replace `020000...` with your actual transaction hex from the IDE. |
| 125 | +## `non-BIP68-final` |
189 | 126 |
|
190 | | -### Step 10: Verify on Explorer |
| 127 | +The sequence is higher than the current block height plus the UTXO height. |
191 | 128 |
|
192 | | -View your transaction: https://blockstream.info/liquidtestnet/tx/YOUR_TXID |
| 129 | +Decrease the sequence or wait until the block height is high enough. |
193 | 130 |
|
194 | | - |
| 131 | +## `dust` |
195 | 132 |
|
196 | | -**Check status via API:** |
197 | | -```bash |
198 | | -curl "https://blockstream.info/liquidtestnet/api/tx/<txid>/status" |
199 | | -``` |
| 133 | +You are creating a dust transaction output. |
200 | 134 |
|
201 | | - |
| 135 | +The fee consumes the entire input value. Decrease the fee. |
202 | 136 |
|
203 | | -Wait for confirmation (usually 1-2 minutes on Liquid testnet). |
| 137 | +## `non-mandatory-script-verify-flag (Assertion failed inside jet)` |
204 | 138 |
|
205 | | -**Explorer views:** |
206 | | -- Transaction details: https://blockstream.info/liquidtestnet/tx/TXID |
207 | | -- Address UTXOs: https://blockstream.info/liquidtestnet/address/ADDRESS |
208 | | -- Mempool: https://blockstream.info/liquidtestnet |
| 139 | +A Simplicity jet fails. |
209 | 140 |
|
210 | | ---- |
| 141 | +Double-check the conditions that your SimplicityHL program enforces. Update the witness data or transaction parameters. |
211 | 142 |
|
212 | | -## Common Workflows |
| 143 | +Every time you change the transaction parameters, the signature hash of the transaction changes. In this case, you need to **regenerate signatures** using the "Key Store" tab. |
213 | 144 |
|
214 | | -### P2PK Contract |
| 145 | +## `non-mandatory-script-verify-flag (Witness program hash mismatch)` |
215 | 146 |
|
216 | | -**Code:** |
217 | | -```rust |
218 | | -fn main() { |
219 | | - let pk: Pubkey = 0x02...; |
220 | | - let msg: u256 = jet::sig_all_hash(); |
221 | | - let sig: Signature = witness::signature; |
222 | | - jet::bip_0340_verify(pk, msg, sig) |
223 | | -} |
224 | | -``` |
| 147 | +The CMR of the Simplicity program inside the UTXO is different from the CMR of the program inside the transaction input. |
225 | 148 |
|
226 | | -**Steps:** |
227 | | -1. Compile contract |
228 | | -2. Fund P2TR address |
229 | | -3. Compute sighash (IDE shows this) |
230 | | -4. Sign sighash externally |
231 | | -5. Enter signature in witness field |
232 | | -6. Build and broadcast |
233 | | - |
234 | | -### Time-Locked Contract |
235 | | - |
236 | | -**Code:** |
237 | | -```rust |
238 | | -fn main() { |
239 | | - jet::check_lock_time(1735689600); |
240 | | -} |
241 | | -``` |
242 | | - |
243 | | -**Steps:** |
244 | | -1. Compile and fund |
245 | | -2. Wait until timestamp |
246 | | -3. Build transaction (no special witness) |
247 | | -4. Broadcast after timestamp |
248 | | - |
249 | | ---- |
| 149 | +Use a backup to restore the original program that you used to create the UTXO. Alternatively, try to fix your current program to match the UTXO program. |
250 | 150 |
|
251 | 151 | ## Web IDE Internals |
252 | 152 |
|
@@ -274,52 +174,8 @@ fn main() { |
274 | 174 | 5. Build complete witness stack |
275 | 175 | 6. Serialize transaction to hex |
276 | 176 |
|
277 | | - |
278 | | ---- |
279 | | - |
280 | | -## Troubleshooting |
281 | | - |
282 | | -### Compilation Errors |
283 | | - |
284 | | -**Error:** `Parameter X is missing an argument` |
285 | | - |
286 | | -**Solution:** Provide argument in witness or parameters section |
287 | | - |
288 | | -### Transaction Rejected |
289 | | - |
290 | | -**Error:** `bad-txns-inputs-missingorspent` |
291 | | - |
292 | | -**Solution:** UTXO already spent or doesn't exist. Check: |
293 | | -```bash |
294 | | -curl "https://blockstream.info/liquidtestnet/api/address/tex1p.../utxo" |
295 | | -``` |
296 | | - |
297 | | -### Signature Invalid |
298 | | - |
299 | | -**Error:** Program returns false |
300 | | - |
301 | | -**Solution:** |
302 | | -- Verify sighash is correct |
303 | | -- Check signature is BIP-340 Schnorr (64 bytes) |
304 | | -- Ensure public key matches |
305 | | - |
306 | | ---- |
307 | | - |
308 | | -## Limitations |
309 | | - |
310 | | -**Web IDE limitations:** |
311 | | -- Testnet only (no mainnet) |
312 | | -- Basic transaction building (single input/output) |
313 | | -- No complex covenant testing |
314 | | -- Browser-based (no local storage) |
315 | | - |
316 | | -**For production:** Use CLI tools (simply, elements-cli) |
317 | | - |
318 | | ---- |
319 | | - |
320 | 177 | ## Next Steps |
321 | 178 |
|
322 | 179 | - **Learn SimplicityHL:** [Language Reference](../simplicityhl-reference/) |
323 | 180 | - **CLI Development:** [Simply CLI Guide](simply-cli-guide.md) |
324 | 181 | - **Use Cases:** [Example Contracts](../use-cases/) |
325 | | - |
0 commit comments