Scripting 101
+Create an OP_RETURN
-Learn the basics of scripting. Scripts are array-like objects with some helper functions.
- Start › +This example creates a transaction with output containing a null data script with our data.
+ Start ›diff --git a/guides-markdown/op_return.md b/guides-markdown/op_return.md index 24f4af5..67ab523 100644 --- a/guides-markdown/op_return.md +++ b/guides-markdown/op_return.md @@ -15,31 +15,31 @@ This example creates a transaction with output containing a null data script with our data: ```javascript - const bcoin = require("bcoin"); - - let id, passphrase, rate, script, output; - id="primary" - passphrase="pass" - rate=5000 - script = bcoin.script.fromNulldata(Buffer.from("with ❤︎ from bcoin")) - output = bcoin.output.fromScript(script, 0) - - const httpWallet = bcoin.http.Wallet({ - id: id, - network: 'testnet' - }); - - - const options = { - rate: rate, - outputs: [output], - passphrase: passphrase - }; - - (async () => { - const tx = await httpWallet.send(options); - console.log(tx); - })(); +const bcoin = require("bcoin"); + +let id, passphrase, rate, script, output; +id="primary" +passphrase="pass" +rate=5000 +script = bcoin.script.fromNulldata(Buffer.from("with ❤︎ from bcoin")) +output = bcoin.output.fromScript(script, 0) + +const httpWallet = bcoin.http.Wallet({ + id: id, + network: 'testnet' +}); + + +const options = { + rate: rate, + outputs: [output], + passphrase: passphrase +}; + +(async () => { + const tx = await httpWallet.send(options); + console.log(tx); +})(); ``` As an example, here is a transaction created on testnet using the above script: 3bfced561161ce4378132fabe72dd2a1fb8654ceed3d4ceb554f2bb7420b86e7 diff --git a/guides-markdown/scripting.md b/guides-markdown/scripting.md index ab42101..279a3df 100644 --- a/guides-markdown/scripting.md +++ b/guides-markdown/scripting.md @@ -1,4 +1,4 @@ -# Scripting +# Intro to Scripting ```post-author Christopher Jeffery diff --git a/guides.html b/guides.html index e77b13f..a787fb3 100644 --- a/guides.html +++ b/guides.html @@ -260,7 +260,8 @@
Learn the basics of scripting. Scripts are array-like objects with some helper functions.
- Start › +This example creates a transaction with output containing a null data script with our data.
+ Start ›This example creates a transaction with output containing a null data script with our data:
- const bcoin = require("bcoin");
-
- let id, passphrase, rate, script, output;
- id="primary"
- passphrase="pass"
- rate=5000
- script = bcoin.script.fromNulldata(Buffer.from("with ❤︎ from bcoin"))
- output = bcoin.output.fromScript(script, 0)
-
- const httpWallet = bcoin.http.Wallet({
- id: id,
- network: 'testnet'
- });
-
-
- const options = {
- rate: rate,
- outputs: [output],
- passphrase: passphrase
- };
-
- (async () => {
- const tx = await httpWallet.send(options);
- console.log(tx);
- })();
As an example, here is a transaction created on testnet using the above script: 3bfced561161ce4378132fabe72dd2a1fb8654ceed3d4ceb554f2bb7420b86e7
+const bcoin = require("bcoin");
+
+let id, passphrase, rate, script, output;
+id="primary"
+passphrase="pass"
+rate=5000
+script = bcoin.script.fromNulldata(Buffer.from("with ❤︎ from bcoin"))
+output = bcoin.output.fromScript(script, 0)
+
+const httpWallet = bcoin.http.Wallet({
+ id: id,
+ network: 'testnet'
+});
+
+
+const options = {
+ rate: rate,
+ outputs: [output],
+ passphrase: passphrase
+};
+
+(async () => {
+ const tx = await httpWallet.send(options);
+ console.log(tx);
+})();
As an example, here is a transaction created on testnet using the above script: 3bfced561161ce4378132fabe72dd2a1fb8654ceed3d4ceb554f2bb7420b86e7
One can verify this by fetching the transaction and converting its output signature script to ascii string.
diff --git a/guides/scripting.html b/guides/scripting.html index 64b675e..0642a82 100644 --- a/guides/scripting.html +++ b/guides/scripting.html @@ -302,7 +302,7 @@Scripts are array-like objects with some helper functions.
+Scripts are array-like objects with some helper functions.
var bcoin = require('bcoin');
var assert = require('assert');
var BN = bcoin.bn;