Skip to content

Instantly share code, notes, and snippets.

View KardanovIR's full-sized avatar
🥸
Focusing

Inal Kardanov KardanovIR

🥸
Focusing
View GitHub Profile
# In this example multiple accounts can deposit their funds and safely take them back.
# User balances are stored in the dApp state as mapping `address => waves`.
{-# STDLIB_VERSION 4 #-}
{-# CONTENT_TYPE DAPP #-}
{-# SCRIPT_TYPE ACCOUNT #-}
@Callable(i)
func deposit() = {
# deposit function can be invoked from UI by user to top up the balance
@KardanovIR
KardanovIR / table.csv
Last active September 22, 2020 16:34
Language Pros Cons
Solidity Blockchain-specific Many ways “to shoot himself in the leg”
Turing-complete (flexibility) Difficult to write production-ready code
Good developer tools and libraries
Easiness of experimenting
Ride Blockchain-specific Non-Turing complete and no libraries
Easy to write production-ready code
Functional approach
Unlikely to “shoot himself in the leg”
Rust Possibility to find work outside blockchain Too many restrictions
strict z = Invoke(dapp,func,args,[AttachedPayment(unit,100000000)])
// Invoke(dApp: Address|Alias, function: String, arguments: List[Boolean|ByteVector|Int|String|List[Boolean|ByteVector|Int|String]], payments: List[AttachedPayments]): T|Unit
(
[
ScriptTransfer(i.caller,100,unit)
],
42
)
func findString(a: Any) = {
match a {
case a: String => a
case a: List[Any] =>
match a[0] {
case b: String => b
case _ => throw("Data is not a string")
}
case _ => throw("Data is not a string")
}
let allTransactions: Array<any> = [];
let response: any;
let after: null | string = null;
do {
let url = `https://api.wavesplatform.com/v0/transactions/invoke-script?timeStart=2021-10-20T12%3A00%3A00.000Z&dapp=3PAETTtuW7aSiyKtn9GuML3RgtV1xdq1mQW&function=buyPerch&sort=desc&limit=100`;
if (after) {
url += `&after=${after}`
}
response = (await axios.get(url)).data;
import { address as decodeAddress, concat, stringToBytes, verifySignature } from '@waves/ts-lib-crypto';
import { verifyCustomData } from '@waves/waves-transactions';
export function verifyAuthentication(signature: string, publicKey: string, address: string): string | null {
const signedByAddress = decodeAddress({ publicKey });
const messageBytes = stringToBytes(address);
const authDataString = concat([255, 255, 255, 1], messageBytes);
if (
verifyCustomData({