# cypto from petlib.bn import Bn # chainspace from chainspacecontract import ChainspaceContract # coconut from chainspacecontract.examples.coconut_util import pet_pack, pet_unpack, pack, unpackG1, unpackG2 from chainspacecontract.examples.coconut_lib import setup, mix_verify, prepare_mix_sign, verify_mix_sign, mix_sign from chainspacecontract.examples.coconut_lib import show_mix_sign ## contract name contract = ChainspaceContract('coconut') ## dependencies from chainspacecontract.examples.hello import contract as hello_contract contract.register_dependency(hello_contract) import time #################################################################### # methods #################################################################### # ------------------------------------------------------------------ # init # ------------------------------------------------------------------ @contract.method('init') def init(): return { 'outputs': (dumps({'type': 'CoCoToken'}), ), }
"""An example smart contract to demonstrate cross-contract calls.""" from chainspacecontract import ChainspaceContract from chainspacecontract.examples.addition import contract as increment_contract contract = ChainspaceContract('increment_twice') contract.register_dependency(increment_contract) @contract.method('init') def init(): return {'outputs': ('0', )} @contract.method('increment') def increment(inputs, reference_inputs, parameters): integer = int(inputs[0]) increment_contract.increment((parameters[0], ), None, None) return {'outputs': (str(integer + 1), )} if __name__ == '__main__': contract.run()