module TestMoveFrom { resource Counter { i: u64 } public has(): bool { let sender_address: address; let yes: bool; sender_address = get_txn_sender(); yes = exists(move(sender_address)); return move(yes); } public increment() { let sender_address: address; let t_ref: &mut R#Self.Counter; let counter_ref: &mut u64; sender_address = get_txn_sender(); t_ref = borrow_global(move(sender_address)); counter_ref = &mut copy(t_ref).i; release(move(t_ref)); *move(counter_ref) = *copy(counter_ref) + 1; return; } public publish() { let t: R#Self.Counter; t = Counter { i: 0 }; move_to_sender(move(t)); return; } public unpublish() { let sender_address: address; let counter: R#Self.Counter; let i: u64; sender_address = get_txn_sender(); counter = move_from(move(sender_address)); Counter { i } = move(counter); return; } } //! new-transaction import {{default}}.TestMoveFrom; main() { let has1: bool; let has2: bool; TestMoveFrom.publish(); TestMoveFrom.increment(); has1 = TestMoveFrom.has(); assert(move(has1), 77); TestMoveFrom.unpublish(); has2 = TestMoveFrom.has(); assert(!move(has2), 88); return; }