text stringlengths 128 84.3k | output stringclasses 211
values |
|---|---|
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: Implement a general-purpose smart contract.
### Output:
contract Payout =
public function payout(xs : list((address, int))) : int =
payout'(xs, 0)
function payout'(xs : list((address, int)), to... | contract Payout =
public function payout(xs : list((address, int))) : int =
payout'(xs, 0)
function payout'(xs : list((address, int)), total : int) : int =
switch(xs)
[] => total
(address, tokens) :: xs' =>
Chain.spend(address, tokens)
payout'(xs', total + tokens) |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: It should manage internal state effectively.
### Output:
contract Maps =
record pt = {x : int, y : int}
record state = { map_i : map(int, pt),
map_s : map(string, pt) }
entr... | contract Maps =
record pt = {x : int, y : int}
record state = { map_i : map(int, pt),
map_s : map(string, pt) }
entrypoint init() = { map_i = {}, map_s = {} }
entrypoint get_state() = state
// {[k] = v}
entrypoint map_i() =
{ [1] = {x = 1, y = 2},
[2] = {x = 3, y = 4},
... |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: It should manage internal state effectively. It should handle incoming payments securely. It should interact with Aeternity oracles.
### Output:
// AENS tests
contract interface Remote =
entrypoint fo... | // AENS tests
contract interface Remote =
entrypoint foo : () => int
contract AENSTest =
// Name resolution
entrypoint resolve_account(name : string, key : string) : option(address) =
AENSv2.resolve(name, key)
entrypoint resolve_string(name : string, key : string) : option(string) =
AENSv2.resolve(... |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: Implement a general-purpose smart contract.
### Output:
contract Poll =
entrypoint title() = "The Poll"
entrypoint close_height() : option(int) = None | contract Poll =
entrypoint title() = "The Poll"
entrypoint close_height() : option(int) = None |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: Implement a general-purpose smart contract.
### Output:
// Tests of builtin bit fields
contract BitsTest =
entrypoint none() : bits = Bits.none
entrypoint all() ... | // Tests of builtin bit fields
contract BitsTest =
entrypoint none() : bits = Bits.none
entrypoint all() : bits = Bits.all
entrypoint set(b : bits, i : int) : bits = Bits.set(b, i)
entrypoint clear(b : bits, i : int) : bits = Bits.clear(b, ... |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: Implement a general-purpose smart contract.
### Output:
contract Identity =
// type xy = {x:int, y:int}
// type xz = {x:int, z:int}
// type yz = {y:int, z:int}
record point = {x:int,y:int}
reco... | contract Identity =
// type xy = {x:int, y:int}
// type xz = {x:int, z:int}
// type yz = {y:int, z:int}
record point = {x:int,y:int}
record cp('a) = {color: string, p:'a}
//type intpoint = point(int)
// //if (x==42) 1 else (x*x)
// }
//let baz() = {age:3, name:(4:int)}
//let foo(a,b,c) = c
// le... |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: It should manage internal state effectively.
### Output:
contract Chess =
type board = map(int, map(int, string))
type state = board
function get_row(r, m : board) =
Map.lookup_default(r, m, ... | contract Chess =
type board = map(int, map(int, string))
type state = board
function get_row(r, m : board) =
Map.lookup_default(r, m, {})
function set_piece(r, c, p, m : board) =
m { [r] = get_row(r, m) { [c] = p } }
function get_piece(r, c, m : board) =
Map.lookup(c, get_row(r, m))
functio... |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: It should manage internal state effectively.
### Output:
// Test more advanced chain interactions
contract ChainTest =
record state = { last_bf : address }
entrypoint init() : state =
{last_bf... | // Test more advanced chain interactions
contract ChainTest =
record state = { last_bf : address }
entrypoint init() : state =
{last_bf = Contract.address}
entrypoint miner() = Chain.coinbase
stateful entrypoint save_coinbase() =
put(state{last_bf = Chain.coinbase})
entrypoint last_bf() = state.... |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: It should manage internal state effectively.
### Output:
// Testing more interesting state types
contract Stack =
type stack('a) = list('a)
record state = { stack : stack(string),
... | // Testing more interesting state types
contract Stack =
type stack('a) = list('a)
record state = { stack : stack(string),
size : int }
entrypoint init(ss : list(string)) = { stack = ss, size = length(ss) }
function length(xs) =
switch(xs)
[] => 0
_ :: xs => length(xs) + ... |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: Implement a general-purpose smart contract.
### Output:
// Check that we get out of gas/arithmetic errors for big numbers.
contract BigNum =
function mul_(a, b, r) =
if (b =< 0) r
else mul_(a ... | // Check that we get out of gas/arithmetic errors for big numbers.
contract BigNum =
function mul_(a, b, r) =
if (b =< 0) r
else mul_(a + a, b / 2, if (b mod 2 == 1) (a + r) else r)
function mul(a, b) = mul_(a, b, 0)
function pow1_(a, b, r) =
if (b =< 0) r
else pow1_(mul(a, a), b / 2, if (b mod... |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: Implement a general-purpose smart contract.
### Output:
include "String.aes"
contract CryptoTest =
entrypoint sha3_str (s : string) : hash = String.sha3(s)
entrypoint sha256_str (s : string) : ha... | include "String.aes"
contract CryptoTest =
entrypoint sha3_str (s : string) : hash = String.sha3(s)
entrypoint sha256_str (s : string) : hash = String.sha256(s)
entrypoint blake2b_str (s : string) : hash = String.blake2b(s)
type complex = list(option(int) * string)
entrypoint sha3 (x : complex) : has... |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: It should manage internal state effectively.
### Output:
contract Arithmetic =
type state = int
entrypoint init(i : int) =
i
entrypoint read() =
state
entrypoint pow(i : int) =
sw... | contract Arithmetic =
type state = int
entrypoint init(i : int) =
i
entrypoint read() =
state
entrypoint pow(i : int) =
switch(i)
0 => 1
n => state * pow(n - 1)
entrypoint ackermann(x : int, y :int) =
switch(x)
0 => y + 1
_ => switch(y)
0 =>... |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: Implement a general-purpose smart contract.
### Output:
contract Simple =
type t = int => int | contract Simple =
type t = int => int |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: It should manage internal state effectively. It should handle incoming payments securely.
### Output:
/*
* A simple crowd-funding example
*/
contract FundMe =
record spend_args = { recipient : addre... | /*
* A simple crowd-funding example
*/
contract FundMe =
record spend_args = { recipient : address,
amount : int }
record state = { contributions : map(address, int),
total : int,
beneficiary : address,
deadline :... |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: It should manage internal state effectively.
### Output:
contract Sorting =
// Allow sorting the state
type state = list(int)
entrypoint init(l : list(int)) = l
stateful entrypoint state_sort(... | contract Sorting =
// Allow sorting the state
type state = list(int)
entrypoint init(l : list(int)) = l
stateful entrypoint state_sort() =
put(sort(state))
entrypoint sort(l : list(int)) =
switch(l)
[] => []
x :: xs => insert(x, sort(xs))
entrypoint insert(x : int, l : list(int)... |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: It should manage internal state effectively. It should handle incoming payments securely. It should interact with Aeternity oracles.
### Output:
contract Oracles =
type fee = int
type ttl = Chain.tt... | contract Oracles =
type fee = int
type ttl = Chain.ttl
type query_t = string
type answer_t = int
type oracle_id = oracle(query_t, answer_t)
type query_id = oracle_query(query_t, answer_t)
stateful entrypoint registerOracle(acct : address,
qfee : fee,
... |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: It should manage internal state effectively.
### Output:
// Testing garbage collection and inplace update of maps
contract MapsGC =
record state = { a : map(string, string)
, b : map(... | // Testing garbage collection and inplace update of maps
contract MapsGC =
record state = { a : map(string, string)
, b : map(string, string) }
entrypoint init(a, b) = {a = a, b = b}
stateful entrypoint upd_a(k1, k2, v) =
let a = state.a{[k1] = v}
let b = state.a{[k2] = v}
put(stat... |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: It should manage internal state effectively. It should handle incoming payments securely.
### Output:
contract Counter =
record state = { value : int }
entrypoint init(val) = { value = val }
paya... | contract Counter =
record state = { value : int }
entrypoint init(val) = { value = val }
payable entrypoint get() = state.value
stateful payable entrypoint tick() = put(state{ value = state.value + 1 }) |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: It should manage internal state effectively. It should interact with Aeternity oracles.
### Output:
contract TxAuth =
record state = { nonce : int }
entrypoint init() = { nonce = 1 }
stateful ent... | contract TxAuth =
record state = { nonce : int }
entrypoint init() = { nonce = 1 }
stateful entrypoint authorize(n : int) : bool =
require(n >= state.nonce, "Nonce too low")
require(n =< state.nonce, "Nonce too high")
put(state{ nonce = n + 1 })
switch(Auth.tx)
None => abort("Not in A... |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: It should handle incoming payments securely.
### Output:
payable contract Test =
payable entrypoint foo(x : int) =
if (x > Call.value)
true
else
false
entrypoint bar(x : int) =
... | payable contract Test =
payable entrypoint foo(x : int) =
if (x > Call.value)
true
else
false
entrypoint bar(x : int) =
false |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: It should manage internal state effectively.
### Output:
/*
contract interface AeToken {
function balanceOf(address addr) returns (uint256)
}
contract AEProof {
AeToken aeToken
mapping (bytes32 => P... | /*
contract interface AeToken {
function balanceOf(address addr) returns (uint256)
}
contract AEProof {
AeToken aeToken
mapping (bytes32 => Proof) private proofs
mapping (address => bytes32[]) private proofsByOwner
function AEProof(address tokenAddress) {
aeToken = AeToken(tokenAddress)
}
struct Proof {
... |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: Implement a general-purpose smart contract.
### Output:
include "String.aes"
contract Strings =
entrypoint str_len(s) = String.length(s)
entrypoint str_concat(s1, s2) = String.concat(s1, s2)
... | include "String.aes"
contract Strings =
entrypoint str_len(s) = String.length(s)
entrypoint str_concat(s1, s2) = String.concat(s1, s2)
entrypoint str_split(n, s) = String.split(n, s)
entrypoint str_at(n, s) = String.at(n, s)
entrypoint str_tokens(s, t) = String.tokens(s, t)
entrypoint str... |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: Implement a general-purpose smart contract.
### Output:
contract BadCode =
entrypoint main_(x : int) = x mod x | contract BadCode =
entrypoint main_(x : int) = x mod x |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: It should handle incoming payments securely.
### Output:
contract Identity =
payable entrypoint main_ (x:int) = x | contract Identity =
payable entrypoint main_ (x:int) = x |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: It should manage internal state effectively. It should handle incoming payments securely. It should emit events for transparency.
### Output:
payable contract PaymentSplitter =
record state =
{ ... | payable contract PaymentSplitter =
record state =
{ owner: address,
recipientConditions: map(address, int), // map of recipients with percentage to receive (value between 1 and 100)
totalAmountSplitted: int }
// CONTRACT EVENTS
datatype event = AddingInitialRecipients()
| Recipi... |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: Implement a general-purpose smart contract.
### Output:
contract Functions =
function curry(f : ('a, 'b) => 'c) =
(x) => (y) => f(x, y)
function map(f : 'a => 'b, xs : list('a)) =
switch(xs)
... | contract Functions =
function curry(f : ('a, 'b) => 'c) =
(x) => (y) => f(x, y)
function map(f : 'a => 'b, xs : list('a)) =
switch(xs)
[] => []
x :: xs => f(x) :: map(f, xs)
function map'() = map
function plus(x, y) = x + y
entrypoint test1(xs : list(int)) = map(curry(plus)(5), xs)
entry... |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: It should manage internal state effectively. It should handle incoming payments securely.
### Output:
include "String.aes"
contract CoinToss =
record state = { player : address,
... | include "String.aes"
contract CoinToss =
record state = { player : address,
casino : address,
hash : option(hash),
height : int,
casino_pick : option(string),
stake : int... |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: Implement a general-purpose smart contract.
### Output:
include "String.aes"
contract interface BytesRemote =
entrypoint split_any : (bytes(), int) => option(bytes() * bytes())
entrypoint concat : (... | include "String.aes"
contract interface BytesRemote =
entrypoint split_any : (bytes(), int) => option(bytes() * bytes())
entrypoint concat : (bytes(), bytes()) => bytes()
entrypoint to_fixed : (bytes()) => option(bytes(4))
entrypoint to_any : (bytes(4)) => bytes()
entrypoint int_to_bytes : (int, int) => byte... |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: Implement a general-purpose smart contract.
### Output:
contract SafeMath =
entrypoint add(x, y) = x + y
entrypoint sub(x, y) = x - y
entrypoint mul(x, y) = x * y
entrypoint div(x, y) = x / y
... | contract SafeMath =
entrypoint add(x, y) = x + y
entrypoint sub(x, y) = x - y
entrypoint mul(x, y) = x * y
entrypoint div(x, y) = x / y
entrypoint rem(x, y) = x mod y
entrypoint pow(x, y) = x ^ y |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: Implement a general-purpose smart contract.
### Output:
include "List.aes"
contract ListComp =
entrypoint sample1() = [1,2,3]
entrypoint sample2() = [4,5]
entrypoint l1() = [x | x <- sampl... | include "List.aes"
contract ListComp =
entrypoint sample1() = [1,2,3]
entrypoint sample2() = [4,5]
entrypoint l1() = [x | x <- sample1()]
entrypoint l1_true() = [1,2,3]
entrypoint l2() = [x + y | x <- sample1(), y <- sample2()]
entrypoint l2_true() = [5,6,6,7,7,8]
entrypoint l3() = [x +... |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: Implement a general-purpose smart contract.
### Output:
include "String.aes"
include "./lib/Library.aes"
contract Includes =
entrypoint test(x: int): int = Library.sum(x, 4)
entrypoint getLengt... | include "String.aes"
include "./lib/Library.aes"
contract Includes =
entrypoint test(x: int): int = Library.sum(x, 4)
entrypoint getLength(x: string): int = String.length(x) |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: Implement a general-purpose smart contract.
### Output:
include"lib/Sublibrary.aes"
namespace Library =
function sum(x: int, y: int): int = Sublibrary.sum(x, y) | include"lib/Sublibrary.aes"
namespace Library =
function sum(x: int, y: int): int = Sublibrary.sum(x, y) |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: Implement a general-purpose smart contract.
### Output:
namespace Sublibrary =
function sum(x: int, y: int): int = x + y | namespace Sublibrary =
function sum(x: int, y: int): int = x + y |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: Implement a general-purpose smart contract.
### Output:
contract Decrement =
entrypoint decrement: (int) => int | contract Decrement =
entrypoint decrement: (int) => int |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: Implement a general-purpose smart contract.
### Output:
include "String.aes"
include "./lib/DecrementInterface.aes"
main contract Increment =
entrypoint increment: (int) => int | include "String.aes"
include "./lib/DecrementInterface.aes"
main contract Increment =
entrypoint increment: (int) => int |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: Implement a general-purpose smart contract.
### Output:
contract Identity =
entrypoint getArg(z : int) = z | contract Identity =
entrypoint getArg(z : int) = z |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: It should manage internal state effectively.
### Output:
contract BlindAuth =
record state = { owner : address }
entrypoint init(owner' : address) = { owner = owner' }
stateful entrypoint authorize... | contract BlindAuth =
record state = { owner : address }
entrypoint init(owner' : address) = { owner = owner' }
stateful entrypoint authorize(r: int) : bool =
// r is a random number only used to make tx hashes unique
switch(Auth.tx_hash)
None => abort("Not in Auth context")
Some(tx_h... |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: It should manage internal state effectively.
### Output:
contract SimpleStorage =
record state = { data : int }
entrypoint init(value : int) : state = { data = value }
function get() : int = state.... | contract SimpleStorage =
record state = { data : int }
entrypoint init(value : int) : state = { data = value }
function get() : int = state.data
stateful function set(value : int) = put(state{data = value}) |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: Implement a general-purpose smart contract.
### Output:
namespace TestLib =
function sum(x: int, y: int) : int = x + y | namespace TestLib =
function sum(x: int, y: int) : int = x + y |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: It should manage internal state effectively. It should handle incoming payments securely.
### Output:
@compiler >= 7
@compiler < 9
include "testLib.aes"
contract Identity =
record state = { z: int }
... | @compiler >= 7
@compiler < 9
include "testLib.aes"
contract Identity =
record state = { z: int }
entrypoint init(_z: int) = { z = _z }
entrypoint test(x : int, y: int) = TestLib.sum(x, TestLib.sum(y, state.z))
entrypoint getMap(): map(int, int) = {[1] = 2, [3] = 4}
payable entrypoint pay() = 0 |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: It should manage internal state effectively. It should emit events for transparency.
### Output:
@compiler >= 6
main contract Example =
type state = option(int)
datatype event = SetXEvent(address, ... | @compiler >= 6
main contract Example =
type state = option(int)
datatype event = SetXEvent(address, int)
entrypoint init() : state = None
stateful entrypoint set(x : int) : unit =
Chain.event(SetXEvent(Call.caller, x))
put(Some(x))
entrypoint get() : int =
switch(state)
None => abort("NO... |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: It should manage internal state effectively. It should handle incoming payments securely. It should emit events for transparency.
### Output:
@compiler >= 6
include "List.aes"
include "Pair.aes"
// the... | @compiler >= 6
include "List.aes"
include "Pair.aes"
// the contract allows for definition of unlimited separate auctions, meant to be in one pysical location, i.e. one event
// each bids includes reference to ipfs files, for this usecase svg files
// bids that are paying lower than the sufficient amount are refunded... |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: Implement a general-purpose smart contract.
### Output:
include "List.aes"
include "Option.aes"
include "Pair.aes"
namespace Set =
record set('a) = { to_map : map('a, unit) }
function new() : set('... | include "List.aes"
include "Option.aes"
include "Pair.aes"
namespace Set =
record set('a) = { to_map : map('a, unit) }
function new() : set('a) =
{ to_map = {} }
function member(e : 'a, s : set('a)) : bool =
Map.member(e, s.to_map)
function insert(e : 'a, s : set('a)) : set('a) =
{ to_map = s.to... |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: Implement a general-purpose smart contract.
### Output:
include "String.aes"
namespace Frac =
private function gcd(a : int, b : int) =
if (b == 0) a else gcd(b, a mod b)
private function abs_i... | include "String.aes"
namespace Frac =
private function gcd(a : int, b : int) =
if (b == 0) a else gcd(b, a mod b)
private function abs_int(a : int) = if (a < 0) -a else a
datatype frac = Pos(int, int) | Zero | Neg(int, int)
/** Checks if the internal representation is correct.
* Numerator and denominat... |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: Implement a general-purpose smart contract.
### Output:
namespace Func =
function id(x : 'a) : 'a = x
function const(x : 'a) : 'b => 'a = (_) => x
function flip(f : ('a, 'b) => 'c) : ('b, 'a) =>... | namespace Func =
function id(x : 'a) : 'a = x
function const(x : 'a) : 'b => 'a = (_) => x
function flip(f : ('a, 'b) => 'c) : ('b, 'a) => 'c = (b, a) => f(a, b)
function comp(f : 'b => 'c, g : 'a => 'b) : 'a => 'c = (x) => f(g(x))
function pipe(f : 'a => 'b, g : 'b => 'c) : 'a => 'c = (x) => g(f(x))
... |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: Implement a general-purpose smart contract.
### Output:
include "ListInternal.aes"
namespace List =
function is_empty(l : list('a)) : bool = switch(l)
[] => true
_ => false
function first... | include "ListInternal.aes"
namespace List =
function is_empty(l : list('a)) : bool = switch(l)
[] => true
_ => false
function first(l : list('a)) : option('a) = switch(l)
[] => None
h::_ => Some(h)
function tail(l : list('a)) : option(list('a)) = switch(l)
[] => None
_::t => Some(... |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: Implement a general-purpose smart contract.
### Output:
namespace Pair =
function fst(t : ('a * 'b)) : 'a = switch(t)
(x, _) => x
function snd(t : ('a * 'b)) : 'b = switch(t)
(_, y) => y
/... | namespace Pair =
function fst(t : ('a * 'b)) : 'a = switch(t)
(x, _) => x
function snd(t : ('a * 'b)) : 'b = switch(t)
(_, y) => y
/** Map over first
*/
function map1(f : 'a => 'c, t : ('a * 'b)) : ('c * 'b) = switch(t)
(x, y) => (f(x), y)
/** Map over second
*/
function map2(f : 'b => 'c, t :... |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: Implement a general-purpose smart contract.
### Output:
namespace Option =
function is_none(o : option('a)) : bool = switch(o)
None => true
Some(_) => false
function is_some(o : option('a))... | namespace Option =
function is_none(o : option('a)) : bool = switch(o)
None => true
Some(_) => false
function is_some(o : option('a)) : bool = switch(o)
None => false
Some(_) => true
/** Catamorphism on `option`. Also known as inlined pattern matching.
*/
function match(n : 'b, s : 'a => 'b, o... |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: Implement a general-purpose smart contract.
### Output:
namespace Triple =
function fst(t : ('a * 'b * 'c)) : 'a = switch(t)
(x, _, _) => x
function snd(t : ('a * 'b * 'c)) : 'b = switch(t)
... | namespace Triple =
function fst(t : ('a * 'b * 'c)) : 'a = switch(t)
(x, _, _) => x
function snd(t : ('a * 'b * 'c)) : 'b = switch(t)
(_, y, _) => y
function thd(t : ('a * 'b * 'c)) : 'c = switch(t)
(_, _, z) => z
/** Map over first
*/
function map1(f : 'a => 'm, t : ('a * 'b * 'c)) : ('m * 'b... |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: Implement a general-purpose smart contract.
### Output:
namespace BLS12_381 =
type fr = MCL_BLS12_381.fr
type fp = MCL_BLS12_381.fp
record fp2 = { x1 : fp, x2 : fp }
record g1 = { x : fp, ... | namespace BLS12_381 =
type fr = MCL_BLS12_381.fr
type fp = MCL_BLS12_381.fp
record fp2 = { x1 : fp, x2 : fp }
record g1 = { x : fp, y : fp, z : fp }
record g2 = { x : fp2, y : fp2, z : fp2 }
record gt = { x1 : fp, x2 : fp, x3 : fp, x4 : fp, x5 : fp, x6 : fp,
x7 : fp, x8 : fp, x9 : ... |
### Instruction:
Write a Sophia smart contract that implements the following functionality based on best practices: It should interact with Aeternity oracles.
### Output:
namespace AENSCompat =
// Translate old format to new format - always possible
function pointee_to_V2(p : AENS.pointee) : AENSv2.pointee =
... | namespace AENSCompat =
// Translate old format to new format - always possible
function pointee_to_V2(p : AENS.pointee) : AENSv2.pointee =
switch(p)
AENS.AccountPt(a) => AENSv2.AccountPt(a)
AENS.OraclePt(a) => AENSv2.OraclePt(a)
AENS.ContractPt(a) => AENSv2.ContractPt(a)
AENS.ChannelP... |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 3