This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Waves from "@waves/signer"; | |
import Provider from "@waves.exchange/provider-web"; | |
// setting the TestNet Signer | |
const waves = new Waves({NODE_URL: 'https://pool.testnet.wavesnodes.com'}); | |
// setting the Waves.Exchange provider | |
const provider = new Provider('https://testnet.waves.exchange/signer/'); | |
waves.setProvider(provider); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<main> | |
<button class="js-login">Authorization</button><br><br> | |
<button class="js-invoke">Invoke Script</button><br> | |
<button class="js-data">Send Data</button> | |
<button class="js-transfer">Send Transfer</button> | |
</main> | |
<script src="../dist/dapp.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.querySelector(".js-login").addEventListener("click", async function(event) { | |
try { | |
const userData = await waves.login(); // calling Waves Signer | |
event.target.classList.add("clicked"); | |
event.target.innerHTML = ` | |
authorized as <br> | |
${userData.address}`; // getting account address | |
} catch (e) { | |
console.error('login rejected') // handling user auth reject | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// calling a "faucet" script wavesexplorer.com/tesnet/address/3MuN7D8r19zdvSpAd1L91Gs88bcgwUFy2mn/script | |
// this will top up the account balance, but only once | |
document.querySelector(".js-invoke").addEventListener("click", function() { | |
waves.invoke({ | |
dApp: "3MuN7D8r19zdvSpAd1L91Gs88bcgwUFy2mn", | |
call: { | |
function: "faucet" | |
} | |
}).broadcast().then(console.log) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// just putting some data into account storage | |
document.querySelector(".js-data").addEventListener("click", function() { | |
waves.data({ | |
data: [ | |
{key: "lastCall", value: String(new Date()), type: 'string'} | |
] | |
}).broadcast().then(console.log) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// just transferring some WAVES token to Alice | |
document.querySelector(".js-transfer").addEventListener("click", function() { | |
waves.transfer({ | |
recipient: "3MuN7D8r19zdvSpAd1L91Gs88bcgwUFy2mn", | |
amount: 1, | |
attachment: base58("Happy New Year!") | |
}).broadcast().then(console.log) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Signer from '@waves/signer'; | |
import { ProviderSeed } from '@waves/provider-seed'; | |
import { libs } from '@waves/waves-transactions'; | |
const seed = libs.crypto.randomSeed(15); | |
const waves = new Signer({ | |
// Specify URL of the node on Testnet | |
NODE_URL: 'https://pool.testnet.wavesnodes.com' | |
}); | |
waves.setProvider(new ProviderSeed(seed)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="main"> | |
<h1>verify <strong>certificado</strong><br>using blockchain</h1><br> | |
<textarea class="data" name="data" id="" cols="30" rows="3">1 Sasha Ivanov</textarea><br> | |
<button style="font-size: 18px" onclick="console.log(checkData());">check certificado!</button> | |
<br> | |
<div class="result">is the certificado real?</div> | |
<div>check it in blockchain: <a target="_blank" style="color: blue; text-decoration: none" href="https://wavesexplorer.com/testnet/address/3N6EmqqQ1pZderX8sNMrfVuEo85ocPoqs2M/data"> | |
https://wavesexplorer.com/testnet/address/<br> | |
3N6EmqqQ1pZderX8sNMrfVuEo85ocPoqs2M/data | |
</a></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function checkData() { | |
const text = document.querySelector(".data").value.split("\n")[0]; | |
const certificateId = text.split(" ")[0]; | |
const xhr = new XMLHttpRequest(); | |
xhr.open("GET", "https://testnodes.wavesnodes.com/addresses/data/3N6EmqqQ1pZderX8sNMrfVuEo85ocPoqs2M/"+certificateId); | |
xhr.onload = function() { | |
const doesExist = JSON.parse(xhr.response).value === text; | |
document.querySelector(".result").innerHTML = doesExist ? "<span style='color: green'><strong>certificado</strong> exists</span>" : "<span style='color: red'><strong>certificado</strong> does not exist</span>"; | |
return doesExist; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener("DOMContentLoaded", function() { | |
document.querySelector(".data").value = location.href.split("?")[1] | |
.replace("%20", " ") | |
.replace("%20", " "); | |
}); |
OlderNewer