Skip to content

Instantly share code, notes, and snippets.

View vlzhr's full-sized avatar

Vladimir vlzhr

View GitHub Profile
dApp.widget.initWidget("<recipient>", "WAVES");
dApp.widget.initPurchase(TOTALAMOUNT);
@vlzhr
vlzhr / assetInfo.ride
Created May 20, 2020 15:34
Ride assetInfo example
let bitcoinId = base58'8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS'
let x = match assetInfo(bitcoinId) {
case asset:Asset =>
asset.name # bitcoin
case _ => throw("Can't find asset")
}
["a","b","c","d"].indexOf("a")
# >> 0
["a","b","c","d"].contains("a")
# >> true
[1, 2, 3, 4].min()
# >> 1
[1, 2, 3, 4].max()
@vlzhr
vlzhr / certificado.ride
Created March 14, 2020 22:05
simple Certificado Smart Contract on RIDE (Waves)
{-# STDLIB_VERSION 3 #-}
{-# SCRIPT_TYPE ACCOUNT #-}
{-# CONTENT_TYPE DAPP #-}
@Callable(i)
func request (name: String) = {
# verify the certificate is not in data state yet
let wasRequested = match getInteger(this, name) {
case a: Int => true
case _ => false
@vlzhr
vlzhr / invoke-tx-example.js
Created March 12, 2020 21:15
Smart Contracts usage tutorial
function q(arg) { return document.querySelector(arg); }
function sendData() {
const text = q(".data").value;
let data = text.split("\n")[0];
const tx = {
type: 16, // invoke transaction
data: {
fee: {
"tokens": "0.005",
@vlzhr
vlzhr / index.js
Created February 10, 2020 12:21
certificado example
function sendData() {
const text = document.querySelector(".data").value;
let data = text.split("\n");
data = data.map(function(x) { return {"key": x.split(" ")[0], "value": x, "type": "string"}} );
const tx = {
type: 12, // data transaction
data: {
data: data,
fee: {
"tokens": "0.001",
@vlzhr
vlzhr / read-blockchain.js
Created February 10, 2020 12:19
Waves Keeper example
WavesKeeper.signAndPublishTransaction({
type: 12,
data: {
data: [
{ key: "string", value: "testVdfgdgf dfgdfgdfg dfg dfg al", type: "string" },
{ key: "binary", value: "base64:AbCdAbCdAbCdAbCdAbCdAbCdAbCdAbCdAbCdAbCdAbCd", type: "binary" },
{ key: "integer", value: 20, type: "integer" },
{ key: "boolean", value: false, type: "boolean" },
],
fee: {
@vlzhr
vlzhr / index.html
Created February 10, 2020 12:14
certificado example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1" name="viewport">
<title>notpaper</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="main">
@vlzhr
vlzhr / check.js
Created February 10, 2020 12:09
certificado example
document.addEventListener("DOMContentLoaded", function() {
document.querySelector(".data").value = location.href.split("?")[1]
.replace("%20", " ")
.replace("%20", " ");
});
@vlzhr
vlzhr / check.js
Created February 10, 2020 11:59
certificado example
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;