Skip to content

Instantly share code, notes, and snippets.

View KardanovIR's full-sized avatar
🥸
Focusing

Inal Kardanov KardanovIR

🥸
Focusing
View GitHub Profile
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({
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;
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")
}
(
[
ScriptTransfer(i.caller,100,unit)
],
42
)
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
@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
# 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
pragma solidity ^0.5.10;
// based on the skeleton file TicTacToe.sol by
// https://github.com/spidfire
contract TicTacToe {
uint[] board = new uint[](9);
address player1;
address player2;
uint whoseTurn = 1;
library GetCode {
function at(address _addr) public view returns (bytes memory o_code) {
assembly {
// retrieve the size of the code, this needs assembly
let size := extcodesize(_addr)
// allocate output byte array - this could also be done without assembly
// by using o_code = new bytes(size)
o_code := mload(0x40)
// new "memory end" including padding
mstore(0x40, add(o_code, and(add(add(size, 0x20), 0x1f), not(0x1f))))
modifier myModifier() {
//do something before the function calls
runningFunction = true;
_;
//do something after the function calls
runningFunction = false;
}
function coolFunction() public payable myModifier() {
// function body here