A trading system for atomically executing a smart contract related to trading between a first blockchain and a second blockchain, the system comprising:
- a coordinator section realized by a first computer and a first user section, realized by a second computer, on the first blockchain;
- and
- a second user section, realized by a third computer, on the second blockchain,
- wherein the coordinator section realized by the first computer, the first user section realized by the second computer, and the second user section realized by the third computer form a distributed network for executing a smart contract related to trading between the first blockchain and the second blockchain;
- wherein the coordinator section realized by the first computer sends a first packet created based on a predetermined transaction in which a contract function of the smart contract is specified to the first user section and the second user section,
- when the contract function in the first packet received from the coordinator section realized by the first computer has been successfully executed, the first user section realized by the second computer saves a change operation performed on a state store associated therewith, acquires a lock for a change target, and sends a second packet with a status set executable to the coordinator section realized by the first computer, whereas when the execution has failed, the first user section realized by the second computer discards the change operation performed on the state store associated therewith and sends a third packet with the status set inexecutable to the coordinator section realized by the first computer,
- when the contract function in the first packet received from the coordinator section realized by the first computer has been successfully executed, the second user section realized by the third computer saves a change operation performed on a state store associated therewith, acquires a lock for a change target, and sends a fourth packet with a status set executable to the coordinator section realized by the first computer, whereas when the execution has failed, the second user section realized by the third computer discards the change operation performed on the state store associated therewith and sends a fifth packet with the status set inexecutable to the coordinator section realized by the first computer,
- the coordinator section realized by the first computer sends a sixth packet to the first user section realized by the second computer and the second user section realized by the third computer to issue a commit request,
- upon receipt of the third packet from the first user section realized by the second computer and/or the fifth packet from the second user section realized by the third computer, the coordinator section realized by the first computer sends a seventh packet to the first user section realized by the second computer and the second user section realized by the third computer to issue an abort request, and
- upon receipt of the sixth packet from the coordinator section, the first user section realized by the second computer and the second user section realized by the third computer apply the change operation saved in advance to the state store, delete the lock, and send an eighth packet to the coordinator section realized by the first computer, whereas upon receipt of the seventh packet from the coordinator section realized by the first computer, the first user section realized by the second computer and the second user section realized by the third computer delete the change operation saved in advance and the lock, and send a ninth packet to the coordinator section realized by the first computer.