Skip to content

Instantly share code, notes, and snippets.

import * as Peps from "../Peps"
let sdk = new Peps.SDK("https://awsapi.wpeps.com", "wss://awsws.wpeps.com")
let clear: Uint8Array
// Alice shares a resource with bob
sdk.login("alice", "password").then(function (session) {
return session.ResourceAPI.create(["alice", "bob"], "my/resource", clear)
}).then(function({id, content}){
@hbbio
hbbio / counter.opa
Last active June 28, 2022 08:56
Code snippets for "What it takes to write solid smart contracts"
import stdlib.themes.bootstrap
database int /counter = 0;
function action(_) {
/counter++;
#msg = <div>Thank you, user {/counter}!</div>
}
function page() {
<span id="msg">Welcome</span>
@hbbio
hbbio / counter.sol
Created June 28, 2022 07:54
Basic counter in Solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;
contract TestCounter {
// public automatically creates the getter
int256 public count = 0;
function increment() public {
count += 1;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function transferOwner(address _owner) public onlyOwner {
owner = _owner;
}
modifier postCondition() {
_;
require(expr);
}