// check: no field type referencing in scripts // TODO is it possible to get this to compile to let the bytecode verifier complain? module Token { resource T {v: u64} public new(v: u64): R#Self.T { return T{v: move(v)}; } public value(this: &R#Self.T): u64 { let vref: &u64; vref = ©(this).v; release(move(this)); return *move(vref); } public exists(addr: address): bool { let yes: bool; yes = exists(move(addr)); return move(yes); } public publish(t: R#Self.T) { move_to_sender(move(t)); return; } } //! new-transaction import {{default}}.Token; main() { let addr: address; let t: R#Token.T; let tref: &mut R#Token.T; let balance_ref: &u64; addr = get_txn_sender(); t = Token.new(1); tref = &mut t; balance_ref = &move(tref).v; release(move(balance_ref)); return; }