diff --git a/CNAME b/CNAME new file mode 100644 index 0000000..4b9676d --- /dev/null +++ b/CNAME @@ -0,0 +1 @@ +tutorials.mvs.org \ No newline at end of file diff --git a/README.md b/README.md index a7b558b..fe2cdc1 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,22 @@ -# MetaverseTutorials +# Metaverse Tutorials Step by step tutorials for the Metaverse Blockchain -This is a Metaverse Tutorial series - -This is a series of Metaverse tutorials. To begin clone this repository - +This is a series of Metaverse tutorials. To begin, clone this repository ``` -git clone https://github.com/antron3000/MetaverseTutorials.git - +git clone https://github.com/mvs-org/MetaverseTutorials.git ``` -navigate to the tutorial directory - +Navigate to the tutorial directory ``` cd MetaverseTutorials ``` -update your repo to the latest version of mvs-blockchain-js +Update your repo to the latest version of mvs-blockchain-js ``` git submodule update --init --recursive ``` Install the metaverse npm package - ``` npm install metaversejs --save ``` @@ -33,49 +27,45 @@ cd mvs-blockchain-js && npm install ``` -Each tutorial builds on the previous ones, so it is recommended to do them in order - -To begin a tutorial navigate to the tutorials folder and follow instructions. +Each tutorial builds on the previous one, so it is recommended to do them in order. Tutorial Information: -These tutorials are designed -* to be simple, no fluff -* hands on -* explain inner workings and give broad understanding of Metaverse blockchain -* Show you step by step how to create dApp on Metaverse. Can also be used to integrate into your existing app. -* provide working examples of what you should have built. -* each tutorial comes with complete solutions to show you how its done in the end. Don't look till you're done! - +These tutorials are designed to: +* Be simple, no fluff +* Be hands-on +* Explain the inner workings and give us a broad understanding of the Metaverse blockchain +* Show you step-by-step how to create dApps on Metaverse and how they can be used to integrate into your existing dApp +* Each tutorial comes with complete solutions to show you how it's done in the end. Don't look till you're done! -1. [Integrate Metaverse wallet into your dapp with your DID](tutorials/1-Metaverse-Wallet) -2. [Issue and transfer MST’s](tutorials/2-Avatars-and-MSTs) -3. [Issue and transfer MIT’s](tutorials/3-MITs) +1. [Integrate Metaverse wallet into your dApp with your DID](tutorials/1-Metaverse-Wallet) +2. [Issue and transfer MST](tutorials/2-Avatars-and-MSTs) +3. [Issue and transfer MIT](tutorials/3-MITs) -For more information refer to the [Metaverse Documentation](https://docs.mvs.org/docs/) +For more information refer to the [Metaverse Documentation](https://docs.mvs.org/docs/). +Also check out some working examples in the `./examples` folder. -Please follow the Environment setup instructions below before starting. +Please follow the "Environment Setup" instructions below before starting. # Environment Setup -Start by entering the "playground" directory. This is where you can build ALL your Metaverse apps during the tutorial. - +Start by entering the `playground` directory. This is where you can build ALL your Metaverse apps during the tutorial. ``` cd tutorials/playground ``` **Interact with metaverse libraries via nodejs** -create a testScript +Create a testScript ``` touch testScript.js ``` -To interact with Metaverse using javascript you can interact with mvs-blockchain-js and metaversejs +To interact with Metaverse using javascript you can interact with `mvs-blockchain-js` and `metaversejs`. -For use in nodejs scripts, import mvs-blockchain from the mvs-blockchain folder, and require metaversjs. +For use in nodejs scripts, import `mvs-blockchain` from the `mvs-blockchain` folder, and require `metaversjs`. -Inside the testscript, add: +Inside the testscript, add the following. You will be using the `blockchain` and `Metaverse` objects later in the other tutorials. ``` //import mvs-blockchain-js @@ -95,13 +85,13 @@ console.log(Metaverse) console.log("Metaversjs has been successfully imported!") ``` -now run +Now run ``` node testScript.js ``` -**Interact with metaverse via webapp** +**Interact with metaverse via web app** First create an html file ``` @@ -120,17 +110,16 @@ and add - ``` -To interact with webapps you must generate "index.js" from mvs-blockchain-js and "metaverse.min.js" from metaversejs. To generate these files you must clone each repository and simply run +To interact with web apps you must generate `index.js` from `mvs-blockchain-js` and `metaverse.min.js` from `metaversejs`. To generate these files you must clone each repository and simply run ``` grunt ``` -This will generate javascript files into the /dist folder that you can import into your app. You don't have to worry about this for now. We have generated these files and placed them in the playground folder. To include them in your webapp just add these script tags into your html page. +This will generate javascript files into the `/dist` folder that you can import into your app. You don't have to worry about this for now. We have generated these files and placed them in the playground folder. To include them in your web app, just add these script tags into your html page. ``` @@ -143,7 +132,6 @@ python -m SimpleHTTPServer 4444 ``` To test that the libraries have been successfully imported into your webpage, open the web console and enter - ``` blockchain = await Blockchain({url: "https://explorer-testnet.mvs.org/api/"}) @@ -152,6 +140,6 @@ blockchain Metaverse ``` -You should see the "blockchain" (from mvs-blockchain-js) and Metaverse (from metaversjs) objects show up in the console. +You should see the "blockchain" (from mvs-blockchain-js) and "Metaverse" (from metaversjs) objects show up in the console. You should now be fully set up and ready to begin [tutorial 1](tutorials/1-Metaverse-Wallet). diff --git a/_config.yml b/_config.yml index ff472d4..abe540e 100644 --- a/_config.yml +++ b/_config.yml @@ -1,2 +1,2 @@ theme: jekyll-theme-minimal -logo: logo.png \ No newline at end of file +logo: images/logo.png \ No newline at end of file diff --git a/_layouts/default.html b/_layouts/default.html index 64f7569..9fec916 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -18,7 +18,7 @@

{% endif %} -

Home

+

Home

Tutorial 1Create Wallet

Tutorial 2Avatars and Smart Token

Tutorial 3Identifiable Token

@@ -48,4 +48,4 @@ {% endif %} - \ No newline at end of file + diff --git a/images/logo.png b/images/logo.png new file mode 100644 index 0000000..8c05056 Binary files /dev/null and b/images/logo.png differ diff --git a/tutorials/1-Metaverse-Wallet/README.md b/tutorials/1-Metaverse-Wallet/README.md index acc2b14..78bce0b 100644 --- a/tutorials/1-Metaverse-Wallet/README.md +++ b/tutorials/1-Metaverse-Wallet/README.md @@ -1,79 +1,69 @@ # Tutorial 1 - Metaverse Wallet -In this tutorial you will learn how to +In this tutorial you will learn how to: * Create a Metaverse wallet -* Import an Existing wallet +* Import an existing wallet * Check your ETP balance * Send transactions programatically -* Integrate wallet into your dApp +* Integrate a wallet into your dApp ## Introduction -Metaverse is a UTXO based blockchain +Metaverse is an **unspent-transaction-output (UTXO)** based blockchain with ETP being the native currency. It is very similar to the way Bitcoin works. -ETP is the native currency of the Metaverse blockchain. To send and receive ETP you need a Metaverse wallet. - -ETP uses a UTXO based model. This means it is very close to the way Bitcoin works. - -Every time you receive a transaction, it becomes a UTXO. -Every time you send a transaction, you collect UTXO's into a transaction input, +Every time you send a transaction, you collect UTXOs into a transaction input, which becomes a UTXO on the receivers end, and the change left over becomes a UTXO on your end. -If this sounds complicated don't worry. Metaverse's library manages UTXO's for you +Every time you receive a transaction, it's a UTXO you can spend. -For more information on UTXO's look here https://komodoplatform.com/whats-utxo/ +If this sounds complicated, don't worry. Metaverse's library manages UTXOs for you. -In Metaverse, as with Bitcoin, you can generate deterministic wallets using by memnonic code words. This gives you multiple addresses you can send and recieve transactions from. +For more information on UTXOs, [look here](https://komodoplatform.com/whats-utxo/) -## Hands on Tutorial +To send and receive ETP you need a Metaverse wallet. +In Metaverse, as with Bitcoin, you can generate deterministic wallets by using memnonic code words. +This gives you multiple addresses you can send and recieve transactions from. -Note: Explicit detailed instructions are given to work with Metaverse, but not always so with HTML elements. If you get stuck with coding HTML elements, you can always refer to w3schools.com +## Hands-on Tutorial -Start by setting up a directory to work in +Note: Explicit detailed instructions are given to work with Metaverse, but not always so with HTML elements. If you get stuck with coding HTML elements, you can always refer to [w3schools.com](https://www.w3schools.com/) +Start by setting up a directory to work in ``` cd MetaverseTutorials/tutorials/playground touch tut1.html touch tut1.js ``` -Create front end - -Open tut1.html and use this HTML front end as the base of your app. - +Open `tut1.html` and use this HTML front-end as the base of your app. ``` - + Tutorial 1 - +

Create new Wallet

-
-

Wallet Details


  • Addresses:
  • Check ETP Balance

    -

    Send ETP

    -


    - - + @@ -81,39 +71,32 @@ Open tut1.html and use this HTML front end as the base of your app. You should now be set up to use the Metaverse javascript libraries. We are using the async/await syntax. The await keyword can only be used in async functions so we will create async functions to perform all actions. -First lets define some key variables - +First let's define some key variables ``` -var wallet //An object representing your Metaverse Wallet -var mnemonic //A mnemonic code word used to generate your Wallet -var addresses //An array containing addresses belonging to the wallet -var balances //A JSON object containing Wallet balances - +let wallet //An object representing your Metaverse Wallet +let mnemonic //A mnemonic code word used to generate your Wallet +let addresses //An array containing addresses belonging to the wallet +let balances //A JSON object containing Wallet balances ``` Start by creating a function to generate a new mnemonic - ``` async function generateMnemonic(){ mnemonic = await Metaverse.wallet.generateMnemonic() } - ``` -And a function to create a Wallet from the mnemonic, using the testnet keyword since we're on the testnet. - - +And a function to create a wallet from the mnemonic, using the testnet keyword since we're on the testnet ``` async function createWallet(){ wallet = await Metaverse.wallet.fromMnemonic(mnemonic,'testnet') - addresses = await wallet.getAddresses() // get list of addresses } ``` -Once you've created a wallet you must get some testnet ETP from the testnet faucet. -A function to get Wallet balances +Once you've created a wallet you must get some testnet ETP from the [testnet faucet](https://free.mvs.org/). +A function to get wallet balances. Note: this is the blockchain object you initialized before. ``` async function getETPBalance(){ @@ -133,23 +116,20 @@ async function getETPBalance(){ return ETPBalance } - ``` -And Finally a function to send ETP - +And finally, a function to send ETP ``` - async function sendETP(amount){ -//Define the amount of ETP you want to send -//Measured in ETP units. There are 100 million units per ETP. - var target = { + //Define the amount of ETP you want to send + //Measured in ETP units. There are 100 million units per ETP. + let target = { ETP: 100000000 //100 million units = 1 ETP }; //Define recipient - var recipient_address = "MVbtobP4m44AKsx5PqBbtrBUdycNHxM3eQ"; + recipient_address = "MVbtobP4m44AKsx5PqBbtrBUdycNHxM3eQ"; //Get latest blockchain length let height = await blockchain.height() @@ -165,7 +145,6 @@ async function sendETP(amount){ //Build the transaction object let tx = await Metaverse.transaction_builder.send(result.utxo, recipient_address, undefined, target, result.utxo[0].address, result.change) - //Sign the transaction with your wallet tx = await wallet.sign(tx) @@ -180,17 +159,16 @@ async function sendETP(amount){ //log amount ETP sent to WHO console.log(tx) } - ``` -## Test NodeJS -To test your nodejs code, Create a function called run() and make sure it gets executed in the script. +## Run and Test -For now, since the metaverse faucet is not operational, use this mnemonic: +To test your nodejs code, Create a function called `run()` and make sure it gets executed in the script. -``` -var mnemonic = "van juice oak general lyrics gravity hammer shield over eager crew volume survey join lonely purchase kitten artwork mass cousin process mixture add knife" +You can use this mnemonic if there are still funds left in it. Or generate your own and load some test ETP from the [faucet](https://free.mvs.org/) mentioned above. +``` +let mnemonic = "van juice oak general lyrics gravity hammer shield over eager crew volume survey join lonely purchase kitten artwork mass cousin process mixture add knife" ``` ``` @@ -206,8 +184,7 @@ async function run(){ } ``` -now in your terminal run - +Now in your terminal run ``` node tut1.js ``` @@ -215,33 +192,27 @@ node tut1.js You should see an ETP balance, and a transaction hash in your terminal. You can take the transaction hash and view the transaction in the [Metaverse Testnet Blockchain Explorer](https://explorer-testnet.mvs.org/). -## Connect to Dapp - -To interact with metaversejs in your webapp, you need to reference metaversejs in your HTML. +## Connect to Your DApp +To interact with `metaversejs` in your web app, you need to reference `metaversejs` in your HTML. ``` ``` -Also reference your tut1.js file. - +Also reference your `tut1.js` file. ``` ``` Next serve the webpage with - - ``` -python -m SimpleHTTPServer 3333 +python -m SimpleHTTPServer 4444 ``` +or however you prefer. -or however you prefer - -Verify that you have connected metaverse to the webapp by opening the browser console and typing "Metaverse". You should see the Metaverse object come up and look something like +Verify that you have connected Metaverse to the web app by opening the browser console and typing "Metaverse". You should see the Metaverse object come up. -_TODO: Expand upon once metaversjs referencing is completed_ -Now connect elements to the js functions and youre done! +Now connect elements to the js functions and you're done! -## Whats next? +## What's Next? Continue with the next tutorial and learn how to [issue and transfer Metaverse Smart Token (MST)](../2-Avatars-and-MSTs) \ No newline at end of file diff --git a/tutorials/1-Metaverse-Wallet/index2.html b/tutorials/1-Metaverse-Wallet/index2.html index 579bdd1..3a85b2b 100644 --- a/tutorials/1-Metaverse-Wallet/index2.html +++ b/tutorials/1-Metaverse-Wallet/index2.html @@ -1,4 +1,5 @@ + @@ -9,35 +10,30 @@ + +

    Create new Wallet

    -

    Create new Wallet

    - - - -

    Send ETP

    - - - -

    Check ETP Balance

    +

    Send ETP

    -

    Issue MST

    +

    Check ETP Balance

    -

    Send MST

    +

    Issue MST

    -

    Deposit

    +

    Send MST

    -

    Create Avatar

    +

    Deposit

    -

    Get Avatar

    +

    Create Avatar

    -

    Create MIT

    +

    Get Avatar

    -

    Transfer MIT

    +

    Create MIT

    -

    Send Multisig transaction

    +

    Transfer MIT

    -

    Send Locked Asset

    +

    Send Multisig transaction

    +

    Send Locked Asset

    diff --git a/tutorials/1-Metaverse-Wallet/solution.html b/tutorials/1-Metaverse-Wallet/solution.html index 736ebfe..ff26a31 100644 --- a/tutorials/1-Metaverse-Wallet/solution.html +++ b/tutorials/1-Metaverse-Wallet/solution.html @@ -2,7 +2,7 @@ - + Tutorial 1 @@ -20,27 +20,19 @@
    Mnemonic
    Addresses and Balances
    - - - - + + + +
    AddressBalance
    AddressBalance

    - -

    Send ETP

    -


    - - - - - - + - + \ No newline at end of file diff --git a/tutorials/1-Metaverse-Wallet/solution.js b/tutorials/1-Metaverse-Wallet/solution.js index 430e8ee..4f3d877 100644 --- a/tutorials/1-Metaverse-Wallet/solution.js +++ b/tutorials/1-Metaverse-Wallet/solution.js @@ -3,17 +3,15 @@ // url: "https://explorer-testnet.mvs.org/api/" // }); -var wallet -var mnemonic -var addresses -var balances +let wallet +let mnemonic +let addresses +let balances -var hidden = true +let hidden = true async function initialize(){ blockchain = await Blockchain({url: "https://explorer-testnet.mvs.org/api/"}) - let test = document.getElementById("addressSelect") - console.log(test) } async function generateMnemonic(){ @@ -41,15 +39,15 @@ async function importWallet() { async function showBalances(){ - var balancesTable = document.getElementById("balancesTable"); + let balancesTable = document.getElementById("balancesTable"); for (i = 0; i < addresses.length; ++i) { - var row = balancesTable.insertRow(i+1); + let row = balancesTable.insertRow(i+1); // Insert new cells ( elements) at the 1st and 2nd position of the "new" element: - var cell1 = row.insertCell(0); - var cell2 = row.insertCell(1); + let cell1 = row.insertCell(0); + let cell2 = row.insertCell(1); // Add some text to the new cells: cell1.innerHTML = addresses[i]; @@ -88,34 +86,32 @@ async function populateAddressSelect() { let anyOption = document.createElement("option"); anyOption.value = addresses anyOption.innerHTML = "any" - addressSelect.appendChild(anyOption) for (i = 0; i < addresses.length; ++i) { - var opt = document.createElement("option"); + let opt = document.createElement("option"); opt.value= [addresses[i]]; opt.innerHTML = addresses[i]; - addressSelect.appendChild(opt); } } async function sendETP(){ - let amount = document.getElementById("sendAmount").innerHTML - var target = { + let amount = document.getElementById("sendAmount").value + let recipient_address = document.getElementById("sendTo").value; + recipient_address = recipient_address.toString() + amount = parseInt(amount) + console.log(amount) + let target = { ETP: amount }; - - var recipient_address = document.getElementById("sendTo").innerHTML; - - console.log(amount) console.log(recipient_address) let height = await blockchain.height() let txs = await blockchain.addresses.txs(addresses) //Get all utxo - let utxos = await Metaverse.output.calculateUtxo(txs.transactions, wallet.getAddresses()) + let utxos = await Metaverse.output.calculateUtxo(txs.transactions, addresses) //Collect utxo for given target let result = await Metaverse.output.findUtxo(utxos, target, height) @@ -136,12 +132,10 @@ async function showHide(){ if(hidden){ document.getElementById("mnemonicLabel").innerHTML = mnemonic document.getElementById("showHideMnemnonic").innerHTML = "Hide" - hidden = false; } else{ document.getElementById("mnemonicLabel").innerHTML = "" document.getElementById("showHideMnemnonic").innerHTML = "Show" - hidden = true; } -} +} \ No newline at end of file diff --git a/tutorials/2-Avatars-and-MSTs/README.md b/tutorials/2-Avatars-and-MSTs/README.md index c4e2499..b559324 100644 --- a/tutorials/2-Avatars-and-MSTs/README.md +++ b/tutorials/2-Avatars-and-MSTs/README.md @@ -1,85 +1,72 @@ -# Tutorial 2 - Avatars and Smart Token +# Tutorial 2 - Avatars and Metaverse Smart Tokens (MST) In this tutorial you will learn how to * Register an Avatar * Verify an Avatar against an address -* Customize and Issue an MST from your Avatar -* Check your MST Balances -* Transfer MST's programatically +* Customize and issue an MST from your Avatar +* Check your MST balances +* Transfer MSTs programatically * Integrate Avatar and MST functionality into your app ## Introduction -Avatars are digital representations of personal Identities that exist on the Metaverse Blockchain -Avatars have an alphanumeric symbol. -Avatars get attached to a Metaverse Address. There can only be one Avatar per address. -ETP and smart tokens can be sent to avatars instead of addresses. -MST's and MIT's can only be issued by Avatars +**Avatars** are digital representations of personal identities -- **digital identitites (DIDs)** -- that exist on the Metaverse Blockchain. +Avatars have unique alphanumeric symbols. An Avatar is attached to exactly one Metaverse address (i.e there can only be at most one Avatar per address). +Transfer of tokens can be done by referring to Avatars instead of addresses. -For more info: https://medium.com/metaverse-blockchain/metaverse-explained-avatars-57be355d42d4 +For more info on Avatars, visit this [article](https://medium.com/metaverse-blockchain/metaverse-explained-avatars-57be355d42d4). -MST's are Metaverse Smart Tokens. MST is Metaverse's fungible token standard. MST's can be seen as subcurrencies on the Metaverse Blockchain. -It costs 10 ETP to create an MST. MST's must be issued by an avatar. +**Metaverse Smart Token (MST)** is Metaverse's fungible token standard. MSTs can be seen as sub-currencies on the Metaverse Blockchain. +It costs 10 ETP to create an MST. The creation and issuance of an MST must be done through an Avatar (i.e. to issue a token, you can't just use a Metaverse address that's not already tied to an Avatar). +Again, ETP and other Metaverse Smart Tokens (MSTs) can be sent to Avatars instead of addresses. -Avatar certifications +There are other things an Avatar can or cannot do and such limitations are defined through a system of **Certificates**. There are three types of certificates on Metaverse: Domain Certificate, Secondary Issue Certificate and Naming Certificate. For more details on what they do, check out this [article](https://medium.com/metaverse-blockchain/metaverse-explained-certificates-b84767d1ae8f). -## Hands on Tutorial - -First lets create an html front end +## Hands-on Tutorial +First let's create an html front-end ``` - + Tutorial 2

    Register Avatar

    - -

    Issue MST

    -
    - -

    Balances

    - - - - - + + + + +
    MSTIssuerAmount
    MSTIssuerAmount

    Send MST

    -

    - ``` -nodejs - -Create a function to register your avatar. - +Now, create a function to register your Avatar. Remember, you'll have to initialize the `wallet` object first (see the previous tutorial). ``` async function registerAvatar(avatar_name,avatar_address) { - let change_address = avatar_address let height = await blockchain.height() let txs = await blockchain.addresses.txs([avatar_address]) @@ -91,97 +78,84 @@ async function registerAvatar(avatar_name,avatar_address) { tx = await tx.toString('hex') tx = await blockchain.transaction.broadcast(tx) } - ``` Create a function to look up an avatar address - ``` - +function getAvatar(avatar) { + return blockchain.avatar.get(avatar); +} ``` - Create a function to issue an MST - ``` - -async function issueMST(issuer,symbol,max_supply,decimalPrecision,issuer,description){ - - - - var recipient_address = issuer; - var change_address = issuer; - - - let wallet = await Metaverse.wallet.fromMnemonic("lunar there win define minor shadow damage lounge bitter abstract sail alcohol yellow left lift vapor tourist rent gloom sustain gym dry congress zero") +async function issueMST(issuer,symbol,max_supply,decimalPrecision,description){ + let issuingAddress = await getAvatar(issuer) + let recipient_address = issuingAddress; + let change_address = issuingAddress; + let height = await blockchain.height() + console.log(issuingAddress) let txs = await blockchain.addresses.txs(wallet.getAddresses()) - let utxos = await Metaverse.transaction_builder.calculateUtxo(txs.transactions, wallet.getAddresses()) //Get all utxo - let result = await Metaverse.transaction_builder.findUtxo(utxos, {}, Metaverse.transaction.ASSET_ISSUE_DEFAULT_FEE) //Collect utxo for given target - let tx = await Metaverse.transaction_builder.issue(result.utxo, recipient_address, symbol, max_supply, precision, issuer, description, change_address, result.change) + let utxos = await Metaverse.output.calculateUtxo(txs.transactions, wallet.getAddresses()) //Get all utxo + let result = await Metaverse.output.findUtxo(utxos, {}, height, 1000000000) //Collect utxo to pay for the fee of 10 ETP + let tx = await Metaverse.transaction_builder.issueAsset(result.utxo, recipient_address, symbol, max_supply, precision, issuer, description, 0,false, change_address, result.change,true,0,'testnet',null,undefined) tx = await wallet.sign(tx) tx = await tx.encode() - console.log(tx.toString('hex')); - + tx = await tx.toString('hex') + tx = await blockchain.transaction.broadcast(tx) + console.log(tx); } - ``` -Create a function to get MST balance - +Create a function to get your MST balance ``` - async function getBalances(){ let wallet = await Metaverse.wallet.fromMnemonic(mnemonic, 'testnet') let height = await blockchain.height() let addresses = wallet.getAddresses() let txs = await blockchain.addresses.txs(addresses) - let utxo = await Metaverse.output.calculateUtxo(txs.transactions, wallet.getAddresses()) let balances = await blockchain.balance.all(utxo, wallet.getAddresses(), height) console.log(balances.MST) - } ``` - -Create a function to transfer MST's - +Create a function to transfer MSTs ``` -async function transferMST() { +async function transferMST(amount,recipient_address,MSTSymbol) { + amount = parseInt(amount) + recipient_address = await getAvatar(recipient_address) + let target = {}; + target[MSTSymbol] = amount + console.log(target) + change_address = wallet.getAddress(0) let height = await blockchain.height() - let txs = await blockchain.addresses.txs(["tDZ5YMLJ3z6VbvAsX1c8oe9hJ2nND4jszz", "t85Hm2nYwQXrry2cVmEHPq8krRdJ7KYjmq"]) - let utxos = await Metaverse.output.calculateUtxo(txs.transactions, ["tDZ5YMLJ3z6VbvAsX1c8oe9hJ2nND4jszz", "t85Hm2nYwQXrry2cVmEHPq8krRdJ7KYjmq"])) //Get all utxo - let result = await Metaverse.output.findUtxo(utxos, target, height)) //Collect utxo for given target - let tx = await Metaverse.transaction_builder.send(result.utxo, recipient_address, undefined, target, change_address, result.change)) - tx = await wallet.sign(tx)) - tx = await tx.encode()) - tx = await blockchain.transaction.broadcast(tx.toString('hex'))) - + let txs = await blockchain.addresses.txs(wallet.getAddresses()) + let utxos = await Metaverse.output.calculateUtxo(txs.transactions, wallet.getAddresses()) //Get all utxo + let result = await Metaverse.output.findUtxo(utxos, target, height) //Collect utxo for given target + let tx = await Metaverse.transaction_builder.send(result.utxo, recipient_address, undefined, target, change_address, result.change) + tx = await wallet.sign(tx) + tx = await tx.encode() + tx = await blockchain.transaction.broadcast(tx.toString('hex')) + console.log(tx) } - ``` -## Connect to your dApp - -To interact with metaversejs in your webapp, you need to reference metaversejs in your HTML. +## Connect to Your DApp +To interact with `metaversejs` in your webapp, you need to reference `metaversejs` in your HTML. ``` - - ``` -Also reference your tut2.js file. - +Also reference your `tut2.js` file. ``` - - ``` -Verify that you have connected metaverse to the webapp by opening the browser console and typing "Metaverse". You should see the Metaverse object come up and look something like +Verify that you have connected metaverse to the webapp by opening the browser console and typing "Metaverse". You should see the Metaverse object come up. -Next connect elements to the js functions and youre done! +Next connect elements to the js functions and you're done! -## Whats next? -Continue with the next tutorial and learn how to work with [Metaverse Identifiable Token (MIT)](../3-MITs) \ No newline at end of file +## What's Next? +Continue with the next tutorial and learn how to work with [Metaverse Identifiable Token (MIT)](../3-MITs) diff --git a/tutorials/2-Avatars-and-MSTs/solution.html b/tutorials/2-Avatars-and-MSTs/solution.html index ee70fd7..66b8564 100644 --- a/tutorials/2-Avatars-and-MSTs/solution.html +++ b/tutorials/2-Avatars-and-MSTs/solution.html @@ -2,60 +2,53 @@ - + Tutorial 2 - -

    Register Avatar