Automatic bookkeeping system and method for real-world assets and legal behaviors based on block chain technology

By building an automated bookkeeping system using blockchain technology and smart contracts, the problem of rights holders being unable to directly exercise their rights is solved, enabling rights holders to exercise their rights directly and for legal actions to be recorded in real time and transparently. This system is applicable to multiple industries.

CN120958477APending Publication Date: 2025-11-14李力
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202580001437.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-13
Publication Date
2025-11-14

AI Technical Summary

Technical Problem

In the real business world, rights holders cannot exercise their rights directly. Agents or trustees may violate rules or promises, resulting in damage to rights and interests, and there is a lack of trust and transparency.

Method used

By leveraging blockchain technology and smart contracts, an automated bookkeeping system can be built, enabling automated and real-time transparent recording of legal acts through register contracts, code of conduct contracts, and manager contracts.

Benefits of technology

It ensures that rights holders can directly exercise their rights, that obligors cannot breach their contracts, and that legal actions are disclosed in real time, thereby reducing costs and improving operational efficiency. It is applicable to traditional industries such as financial services, real estate, and intellectual property, as well as decentralized finance and Web3 systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120958477A_ABST
    Figure CN120958477A_ABST
Patent Text Reader

Abstract

The invention creates a system based on a block chain, and automatically records bookkeeping assets and legal behaviors by using an intelligent contract. The bookkeeping type assets represent property rights, and the governance rights are reflected as role rights in an economic organization. Law behaviors are defined as processes for executing the rights, and the state of the rights can be changed due to the right executing result. According to the system, a model is established by referring to a Turing machine, and the core is to define a structured data object, determine a state transition rule system and realize an algorithm and a process of state evolution. The three types of smart contracts are a register book contract used for defining and recording data objects, a behavior specification contract used for defining rules, and a manager contract used for verifying preconditions and realizing legal consequences. The model automatically controls legal behaviors by using an intelligent contract and records the legal behaviors on a block chain. In order to explain and explain the system, example codes and test scripts are specially included, and specific implementation methods of automatic management legal behaviors and related bookkeeping are displayed in detail.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to blockchain technology, and in particular to second-generation blockchain technology characterized by distributed computing, cryptography, and virtual machine technology, which enables the automated execution of the same computer program code (hereinafter referred to as "smart contract" or "contract") on multiple distributed network nodes using virtual machine technology in the same order and with the same operating instructions. Background Technology

[0002] Blockchain is a distributed ledger technology that enables data sharing, verification, storage, and computation through a distributed network. Blockchain is characterized by its immutability, traceability, security, and trustworthiness, making it suitable for various scenarios such as electronic evidence storage, supply chain management, and digital identity authentication.

[0003] A smart contract is an automatically executed program that represents an agreement between parties in the form of computer code. It implements operations such as adding, deleting, modifying, and querying state variables on the blockchain through specific computational logic. The bytecode compiled from the source code is persistently stored on the blockchain as special state data. Each time it is called to change the state of the blockchain, the operation instructions (hereinafter referred to as "transaction instructions") are written into the block in the order of occurrence, forming a chain of database operation instructions that is immutable, can be verified and executed by multiple parties, and extends one dimension over time.

[0004] The second-generation blockchain system has a unique account system, which is divided into two types: "external accounts" and "contract accounts" (hereinafter collectively referred to as "accounts"):

[0005] "External account" refers to an account controlled by the external account owner, generated using electronic signature technology based on asymmetric encryption algorithms. The external account system of the blockchain system ensures that all smart contract operation instructions triggered off-chain are electronically signed by the external account owner through external clients such as electronic wallets. This enables blockchain nodes and on-chain smart contracts to identify and verify the external account instructions, ensuring that the operation instructions issued by the external account can be effectively identified by its account address (hereinafter referred to as "external account address") and that the data of its instruction content has not been added, modified, or lost.

[0006] A "contract account" refers to an account automatically generated when a smart contract is deployed to a blockchain virtual machine environment, whose control logic is defined by the smart contract that generated it. A contract account can receive and send transaction instructions, triggering the execution of its internal code each time it receives a transaction instruction from an external account or another contract account. The address of a contract account on the blockchain (hereinafter referred to as the "contract account address") is unique and consistent with the external account address in byte length and technical specifications.

[0007] The second-generation blockchain's contract account system enables full-process tracking and identification of read and write operation instructions between on-chain smart contracts. This allows on-chain smart contracts to effectively identify the direct source account of the read and write operation instructions they receive and the account address of the transaction initiating account, thereby further realizing user identification and permission verification in the distributed ledger system. Technical issues

[0008] As human civilization entered the 21st century, the vast majority of wealth exists in the form of book-entry property rights, such as bank deposits, stocks, bonds, real estate, intellectual property rights, fund shares, trust beneficiary rights, bills of lading, warehouse receipts, and various financial products. To define these book-entry property rights, identify their holders, and regulate their transactions, various commercial laws, articles of association, and transaction contracts have been promulgated and established.

[0009] However, in the real business world, rules and promises are often violated: minority shareholders’ right to know and vote is often suppressed because company executives only obey the actual controller; trustees may infringe on the interests of beneficiaries through high-priced related-party transactions, thereby violating their fiduciary duties; and management may mislead investors by disclosing false information.

[0010] The common thread in these failed cases is that the rights holders cannot directly exercise their rights; in other words, they cannot directly achieve the desired legal outcome. They must exercise their rights through an agent or trustee, or require the cooperation of the obligor to achieve their goal. If the agent, trustee, or obligor maliciously violates the rules or promises, the rights holder's interests will be harmed—this is the so-called moral hazard problem. Technical solutions

[0011] Blockchain technology offers a new solution: using an immutable distributed ledger to record book-entry assets and using smart contracts to automatically control the entire process of legal acts. As a result, (1) agents, trustees, or any other intermediaries can completely withdraw from the exercise of legal rights; (2) the right to request the cooperation of the obligor will be transformed into the right to dispose of property, directly changing the state of book-entry assets; (3) legal acts and information disclosure are no longer two independent acts, with no logical difference or time lag. Advanced effects

[0012] By realizing the concept of "code is law," people can rely on the rigid code logic embedded in smart contracts to achieve their transaction goals, thereby replacing trust in the reputation of traditional centralized organizations. This is the essence of "trustlessness" and "decentralization."

[0013] In short, by introducing an automated bookkeeping model based on blockchain technology, business activities can evolve to a new stage: (1) rights holders can exercise their rights directly; (2) obligors have no chance to breach the contract; and (3) legal acts can be disclosed in real time. Attached Figure Description

[0014] There are two main types of information that need to be recorded in business activities: the status of legal rights and the trajectory of legal actions.

[0015] Legal rights can be further divided into the rights of possession, use, income and disposal of book-entered property (hereinafter referred to as "property rights"), and the rights of information, decision-making and voting based on economic organization articles of association and other similar documents (hereinafter referred to as "governance rights").

[0016] Property rights can be defined using data objects such as "stocks" and "bonds" representing the rights of the underlying property; governance rights can be defined using data objects such as "shareholders" and "directors" representing specific roles in an economic organization; and the trajectory of legal acts can be defined using data objects describing the content of an expression of intent (hereinafter referred to as "expression of intent"), such as "voting ballots" or "trading slips." In this way, legal acts can be transformed into unilateral acts of exercising legal rights, and the legal consequences are directly reflected in the creation, modification, or deletion of specific data objects recorded on the blockchain.

[0017] The automated bookkeeping system of the present invention consists of three types of smart contracts: (1) register contract; (2) behavior code contract; and (3) manager contract. In order to ensure that write instructions that can change the state of related smart contracts can only be called by specific external accounts or can only be routed from specific contract accounts, some access control technologies (such as inheriting certain access control smart contracts) need to be adopted during the deployment or initialization of the system. Best mode

[0018] Register Contract These smart contracts record the status of legal rights and the content of legal actions, and can respond to queries for such data in real time. For example, a smart contract called "Share Register" can be used to record the status of the property rights data object "Capital Contribution Certificate," thereby recording attributes such as the type, serial number, face value, shareholder, acquisition price, and voting weight of the relevant shares. Another smart contract called "Shareholder Register" can be used to record the status of the governance rights data object "Shareholder," thereby recording attributes such as the shareholder's account address and the capital contribution certificate number of the shares held. The smart contract "Shareholder Meeting Minutes" can be used to record the expression of intent data object "Voting Ballot," thereby storing voting content such as the voter's account address, voting time, attitude, and voting weight.

[0019] Code of Conduct ContractIt defines the static parameters of legal behavioral norms and can respond to rule queries in real time. For example, in the field of corporate governance, for the voting rule that "ordinary resolutions at shareholders' meetings require the consent of shareholders holding at least 50% of the voting rights to pass," "50%" can be set as the static parameter for voting rules on ordinary resolutions at shareholders' meetings. During the vote counting process for ordinary matters, this rule parameter will be queried from the behavioral norm contract and then compared with the actual voting results. If the voting rights of shareholders who actually voted in favor are greater than or equal to "50%", the motion passes; otherwise, the motion is rejected.

[0020] Management Contract It controls the entire process of every legal act, including two parts: the precondition verification process and the legal result realization process. The preconditions for legal acts include (but do not necessarily cover all) three types: (1) access control restrictions based on the account address of the instruction issuer, (2) time condition restrictions based on the current block timestamp, and (3) legal logic restrictions based on the current attribute value of a specific data object. The operation process for realizing the legal result mainly refers to calling specific write operation functions of specific register contracts to realize the creation, modification, or deletion of relevant data objects.

[0021] Taking shareholder voting as an example, the "shareholder voting" function in the management contract sets up two processes: "precondition verification" and "write operation control".

[0022] In the precondition verification process, the shareholder register contract is first invoked to verify whether the account issuing the instruction has shareholder status. If it does, access control verification is passed. Then, the shareholder meeting minutes contract is invoked to query the voting window period for a specific motion, and then the current block timestamp is queried. If the current timestamp falls within the voting window period, time condition verification is passed. Finally, the shareholder meeting minutes contract is invoked to query whether the program status of a specific motion is "proposed". If so, the verification process based on legal logic restrictions is passed.

[0023] In the write operation control process, the shareholder register contract is called to query all the capital contribution certificate numbers held by the voting shareholders. Then, based on these capital contribution certificate numbers, the total voting weight of all such shares is queried from the equity registration book contract. Finally, the "voting" function of the shareholders' meeting minutes is called to write the calling shareholder's address, total voting rights, and voting attitude into the newly created "voting ballot" data object, thus realizing the result of the legal act of "voting".

[0024] Version control contractOnce a smart contract is deployed, its computational logic and operational flow cannot be changed. Similarly, to ensure the stability and consistency of legal norms, the static parameters of the rules in the behavioral norms contract cannot be modified after they are established. If the computational logic or operational flow of a deployed smart contract needs to be modified, or the rule parameters in the behavioral norms contract need to be modified, a new version of the smart contract must be deployed to replace the old version. To manage different versions of the same type of contract, a special version control register contract can be set up to categorize and record the contract addresses of different versions of contracts and indicate whether the legal validity status of the relevant contracts is "currently valid" or "expired." This method allows for querying data recorded in historical version contracts and also enables logically self-consistent version upgrades and iterations within the system.

[0025] Based on the bookkeeping system constructed by the aforementioned smart contracts, the automated bookkeeping method for legal acts consists of the following steps:

[0026] System initialization After the relevant smart contracts are developed, they need to be deployed to the blockchain network, and some basic data need to be entered into the relevant smart contracts to establish the initial state of the system. In addition, some access control configurations also need to be specially set to ensure that: (1) after the code of conduct is finalized, its editing permission is transferred to the zero address, thereby fixing the rule content; (2) only the manager contract can trigger the write operation function of each register contract.

[0027] Write command reception The manager contract receives a function call instruction for a specific legal act and initiates the predefined precondition verification process and legal result realization process within that function. The manager contract uses a procedural programming approach, treating the specific legal act as an independent process in its function call interface. Starting from the two fundamental goals of precondition verification and legal result realization, it designs the computational logic and operational flow of its source code in a top-down order.

[0028] Prerequisite verificationThe manager contract verifies whether all preconditions for a specific legal act have been met according to a predefined verification process and algorithm. The invocation instruction provides the account address issuing the instruction, as well as retrieval keys for the rule parameters and data objects carried in the input parameters. The verification algorithm generally requires three types of parameters to be retrieved from the system as input: first, static parameters of the behavior rules serving as the judgment standard; second, the current block timestamp representing the time state; and third, attribute values ​​of specific data objects representing the legal rights status or legal act trajectory. After obtaining this input data, the manager contract executes the verification algorithm, verifying whether all conditions are met one by one. If any condition is not met, the process terminates and an error message is returned. Preconditions may include three main categories: "access control restrictions," "time condition restrictions," and "legal logic restrictions," but not every legal act will fully cover all three categories; sometimes, only one or two types of conditions may be verified.

[0029] Legal outcome achieved The administrator contract, following a predefined operational process, invokes relevant functions of a specific register contract to create, modify, or delete specific legal interest data objects or legal action trajectory data objects, thereby achieving the legal outcome of the legal action. There are two intentions behind legal actions: one is to dispose of property rights, and the other is to exercise decision-making or voting rights. The former's legal outcome is reflected in a change in the status of book-entry asset rights, while the latter's legal outcome is reflected in the recording of the content of the legal action. For example, the legal outcome of paying book-entry assets is a change in the holder of those assets, and the legal outcome of voting is recording the voter's attitude and the number of voting rights represented by the ballot.

[0030] When a specific contract in the system undergoes a version upgrade, in order to maintain historical version data and identify the contract address of the currently valid version, the manager contract calls a dedicated function of the version control contract to record the contract address of the new version under the corresponding category in its contract address mapping table, and marks the new contract as "valid" and the old version as "invalid". This is a special operation for system maintenance, distinct from legal acts aimed at achieving business objectives. Industrial applicability

[0031] This invention has significant industrial applicability, addressing inefficiencies and trust issues in asset management and corporate governance. It utilizes blockchain and smart contract technologies to automate legal processes, ensuring real-time transparency, tamper-proof records, and compliance with pre-defined rules. By eliminating intermediaries such as agents and trustees, the system reduces costs and improves operational efficiency. By trusting rigid code logic instead of centralized entities, the system is suitable for traditional industries such as financial services, real estate, and intellectual property, and also perfectly supports modern distributed systems such as decentralized finance, Web3, and decentralized autonomous organizations. Implementation mode of the present invention

[0032] To make the above system and methods easier to understand, a set of sample code developed using Solidity is provided below. The manager contract includes comments explaining in detail the purpose, function, and category of each line of code, clearly identifying the specific steps of the methods described. The sample code consists of six independently deployed smart contracts and two access control middleware contracts for inheritance.

[0033] Share register It is a property rights register contract that defines and records the attributes of the "Certificate of Capital Contribution" data object in terms of equity type, face value, acquisition price, shareholder account address, etc.

[0034] To ensure that only the administrator can access its write operation functions, the share register inherits an access control contract called "Routing Control." During deployment, this contract can assign the special role of "administrator" to specific external accounts, and subsequently, the "administrator" can further transfer this role to the administrator contract. In this way, the share register's write operation functions will be configured to be invoked only by the administrator contract.

[0035] / / RouteControl.sol

[0036] pragma solidity^0.8.8;

[0037] / / The routing control contract is an inheritable middleware contract.

[0038] / / Manage access control for write operation commands.

[0039] contract RouteControl{

[0040] address private_keeper;

[0041] modifier onlyKeeper(){

[0042] require(msg.sender==_keeper,"msgSenderis not keeper");

[0043] _;

[0044] }

[0045] constructor(address keeper){

[0046] _keeper = keeper;

[0047] }

[0048] function setKeeper(address_newKeeper)external onlyKeeper{

[0049] _keeper = _newKeeper;

[0050] }

[0051] function getKeeper()public view returns(address){

[0052] return_keeper;

[0053] }

[0054] }

[0055] / / RegisterOfShares.sol

[0056] pragma solidity^0.8.8;

[0057] import ". / RouteControl.sol";

[0058] / / The share registration book contract is used to record the property rights data object "shares" on the date of issuance, quantity, purchase price, and

[0059] / / Attributes related to the holder.

[0060] contract RegisterOfShares is RouteControl{

[0061] struct Share{

[0062] uint64 seqOfShare;

[0063] uint48 issueDate;

[0064] uint64 amount;

[0065] uint32 price;

[0066] Address shareholder;

[0067] }

[0068] / / seqOfShare=>Share

[0069] mapping(uint=>Share)private_shares;

[0070] modifier shareExist(uint seq){

[0071] require(isShare(seq),"wrong seqOfShare");

[0072] _;

[0073] }

[0074] constructor(address keeper)RouteControl(keeper){}

[0075] function issueShare(address shareholder,uint amount,uint price)

[0076] external onlyKeeper returns(uint64){

[0077] Share memory share=Share({

[0078] seqOfShare:_increaseCounter(),

[0079] issueDate:uint48(block.timestamp),

[0080] amount:uint64(amount),

[0081] price:uint32(price),

[0082] shareholder:shareholder

[0083] });

[0084] _shares[share.seqOfShare]=share;

[0085] _shares[0].amount+=share.amount;

[0086] return share.seqOfShare;

[0087] }

[0088] function_increaseCounter()private returns(uint64){

[0089] _shares[0].seqOfShare++;

[0090] return_shares[0].seqOfShare;

[0091] }

[0092] function removeShare(uint seqOfShare)external onlyKeeper shareExist(seqOfShare){

[0093] Share storage share=_shares[seqOfShare];

[0094] _shares[0].amount-=share.amount;

[0095] delete_shares[seqOfShare];

[0096] }

[0097] function isShare(uint seqOfShare)public view returns(bool){

[0098] return_shares[seqOfShare].issueDate>0;

[0099] }

[0100] function getShare(uint256 seqOfShare)

[0101] external shareExist(seqOfShare)view returns(Share memory){

[0102] return_shares[seqOfShare];

[0103] }

[0104] function getTotalAmount()external view returns(uint64){

[0105] return_shares[0].amount;

[0106] }

[0107] }

[0108] Shareholder register It is a governance register contract used to define and record attributes such as account address and shareholding number of "shareholder" data objects. It also inherits from the routing control contract, ensuring that only the management contract has the right to call write operation functions.

[0109] / / RegisterOfMembers.sol

[0110] pragma solidity^0.8.8;

[0111] import ". / RouteControl.sol";

[0112] / / The shareholder register agreement tracks and records the company's shareholders.

[0113] / / Account address, certificate number of the capital contribution certificate held,

[0114] / / To define and record their legal rights.

[0115] contract RegisterOfMembers is RouteControl{

[0116] struct Member{

[0117] bool isMember;

[0118] mapping(uint=>bool)isInHand;

[0119] mapping(uint=>uint)seqInList;

[0120] uint[]sharesInHand;

[0121] }

[0122] mapping(address=>Member)private_members;

[0123] modifier onlyMember(address acct){

[0124] require(isMember(acct),"acctis not Member");

[0125] _;

[0126] }

[0127] constructor(address keeper)RouteControl(keeper){}

[0128] function addMember(address addr)external onlyKeeper{

[0129] _members[addr].isMember=true;

[0130] }

[0131] function removeMember(address addr)external onlyKeeper{

[0132] delete_members[addr];

[0133] }

[0134] function addShareToMember(

[0135] uint seqOfShare,address acct

[0136] )external onlyKeeper onlyMember(acct){

[0137] require(!isInHandOfMember(seqOfShare,acct),"share alreadyin hand ofmember");

[0138] _members[acct].isInHand[seqOfShare]=true;

[0139] _members[acct].sharesInHand.push(seqOfShare);

[0140] _members[acct].seqInList[seqOfShare]=_members[acct].sharesInHand.length;

[0141] }

[0142] function removeShareFromMember(

[0143] uint seqOfShare,address acct

[0144] )external onlyKeeper onlyMember(acct){

[0145] require(isInHandOfMember(seqOfShare,acct),"share notin hand ofmember");

[0146] uint seqInList=_members[acct].seqInList[seqOfShare];

[0147] uintlen=_members[acct].sharesInHand.length;

[0148] _members[acct].sharesInHand[seqInList]=_members[acct].sharesInHand[len-1];

[0149] _members[acct].sharesInHand.pop();

[0150] _members[acct].isInHand[seqOfShare]=false;

[0151] }

[0152] function isMember(address acct)public view returns(bool){

[0153] return_members[acct].isMember;

[0154] }

[0155] function isInHandOfMember(

[0156] uint seqOfShare,address acct

[0157] )public onlyMember(acct)view returns(bool){

[0158] return_members[acct].isInHand[seqOfShare];

[0159] }

[0160] function getSharesOfMember(

[0161] address acct

[0162] )external onlyMember(acct)view returns(uint[]memory){

[0163] return_members[acct].sharesInHand;

[0164] }

[0165] }

[0166] Shareholders' Meeting Minutes It is an expression of intent register contract used to record "proposals" data objects submitted to the shareholders' meeting for consideration, as well as "voting ballots" data objects representing voting records. It also inherits from the routing control contract, ensuring that only the management contract has the authority to call write operation functions.

[0167] / / GeneralMeetingMinutes.sol

[0168] pragma solidity^0.8.8;

[0169] import ". / RouteControl.sol";

[0170] import". / ShareholdersAgreement.sol";

[0171] / / Shareholders' Meeting Minutes Contract is used to define and record matters related to the resolutions and voting results of shareholders' meetings.

[0172] / / Information on the trajectory of legal actions.

[0173] contract GeneralMeetingMinutes is RouteControl{

[0174] enum TypeOfMotion{

[0175] ZeroPoint,

[0176] ElectOfficer,

[0177] ApproveDoc,

[0178] TransferFund,

[0179] DistributeProfits

[0180] }

[0181] enum StateOfMotion{

[0182] ZeroPoint,

[0183] Created,

[0184] Proposed,

[0185] Passed,

[0186] Rejected,

[0187] Executed

[0188] }

[0189] struct Head{

[0190] uint16 typeOfMotion;

[0191] uint64 seqOfMotion;

[0192] uint16 seqOfVR;

[0193] address proposer;

[0194] }

[0195] struct Body{

[0196] uint48 createDate;

[0197] uint48 proposeDate;

[0198] uint48 shareRegDate;

[0199] uint48 voteStartDate;

[0200] uint48 voteEndDate;

[0201] uint8 para;

[0202] uint8 state;

[0203] }

[0204] struct Motion{

[0205] Head head;

[0206] Body body;

[0207] uint contents;

[0208] }

[0209] enum AttitudeOfVote{

[0210] All,

[0211] Support,

[0212] Against,

[0213] Abstain

[0214] }

[0215] struct Ballot{

[0216] uint8 attitude;

[0217] uint64 weight;

[0218] uint48 sigDate;

[0219] uint64 blocknumber;

[0220] address acct;

[0221] bytes32 sigHash;

[0222] }

[0223] struct Case{

[0224] uint sumOfWeight;

[0225] address[]voters;

[0226] }

[0227] struct Box{

[0228] / / attitude=>Case

[0229] mapping(uint256=>Case)cases;

[0230] / / voter==>Ballot

[0231] mapping(address=>Ballot)ballots;

[0232] }

[0233] struct Repo{

[0234] / / seqOfMotion=>Motion

[0235] mapping(uint256=>Motion)motions;

[0236] / / seqOfMotion=>Box

[0237] mapping(uint256=>Box)boxes;

[0238] }

[0239] Repo private_repo;

[0240] constructor(address keeper)RouteControl(keeper){}

[0241] event CreateMotion(uintindexed seqOfMotion,uintindexed typeOfMotion,uintindexed contents);

[0242] function_increaseCounterOfMotion()private returns(uint64 seq){

[0243] _repo.motions[0].head.seqOfMotion++;

[0244] seq=_repo.motions[0].head.seqOfMotion;

[0245] }

[0246] function_addMotion(uint typeOfMotion,uint seqOfVR,uint contents)private{

[0247] Head memory head=Head({

[0248] typeOfMotion:uint8(typeOfMotion),

[0249] seqOfMotion:_increaseCounterOfMotion(),

[0250] seqOfVR:uint16(seqOfVR),

[0251] proposer:address(0)

[0252] });

[0253] Motion storage m=_repo.motions[head.seqOfMotion];

[0254] m.head=head;

[0255] m.contents=contents;

[0256] m.body.createDate=uint48(block.timestamp);

[0257] m.body.state=uint8(StateOfMotion.Created);

[0258] emit CreateMotion(head.seqOfMotion,typeOfMotion,contents);

[0259] }

[0260] function createMotionToApproveDoc(address addrOfDoc,uint seqOfVR)external onlyKeeper{

[0261] _addMotion(uint8(TypeOfMotion.ApproveDoc),seqOfVR,uint(uint160(addrOfDoc)));

[0262] }

[0263] function proposeMotionToGeneralMeeting(

[0264] uint256 seqOfMotion,address proposer,ShareholdersAgreement.VotingRulememory vr

[0265] )external onlyKeeper{

[0266] Motion storage motion=_repo.motions[seqOfMotion];

[0267] uint48 timestamp=uint48(block.timestamp);

[0268] Body memory body=Body({

[0269] createDate:motion.body.createDate,

[0270] proposeDate:timestamp,

[0271] shareRegDate:timestamp+uint48(vr.invExitDays)*86400,

[0272] voteStartDate:timestamp+uint48(vr.invExitDays+vr.votePrepareDays)*86400,

[0273] voteEndDate:timestamp+uint48(vr.invExitDays+vr.votePrepareDays+vr.votingDays)*86400,

[0274] para:0,

[0275] state:uint8(StateOfMotion.Proposed)

[0276] });

[0277] motion.body=body;

[0278] motion.head.proposer=proposer;

[0279] }

[0280] function castVote(

[0281] uint256 seqOfMotion,uint attitude,bytes32 sigHash,address caller,uintvotes

[0282] )external onlyKeeper{

[0283] Box storage box=_repo.boxes[seqOfMotion];

[0284] Ballot storage b=box.ballots[caller];

[0285] if(b.sigDate==0){

[0286] box.ballots[caller]=Ballot({

[0287] attitude:uint8(attitude),

[0288] weight:uint64(votes),

[0289] sigDate:uint48(block.timestamp),

[0290] blocknumber:uint64(block.number),

[0291] acct:caller,

[0292] sigHash:sigHash

[0293] });

[0294] _pushToCase(box.cases[attitude],b);

[0295] _pushToCase(box.cases[uint8(AttitudeOfVote.All)],b);

[0296] }

[0297] }

[0298] function_pushToCase(Case storage c,Ballot memory b)private{

[0299] c.sumOfWeight+=b.weight;

[0300] c.voters.push(b.acct);

[0301] }

[0302] function voteCounting(

[0303] uint256 seqOfMotion,ShareholdersAgreement.VotingRule memory vr,uinttotalVotes

[0304] )external onlyKeeper{

[0305] Motion storage m=_repo.motions[seqOfMotion];

[0306] Box storage b=_repo.boxes[seqOfMotion];

[0307] bool flag=vr.ratio==0;

[0308] if(!flag){

[0309] flag=(uint(b.cases[uint8(AttitudeOfVote.Support)].sumOfWeight)*

[0310] 10000>=uint(vr.ratio)*totalVotes);

[0311] }

[0312] m.body.state=flag

[0313] ?uint8(StateOfMotion.Passed)

[0314] :uint8(StateOfMotion.Rejected);

[0315] }

[0316] function executeMotion(uint256 seqOfMotion)external onlyKeeper{

[0317] _repo.motions[seqOfMotion].body.state=uint8(StateOfMotion.Executed);

[0318] }

[0319] function getMotion(uint256 seqOfMotion)external view returns(Motionmemory motion){

[0320] motion=_repo.motions[seqOfMotion];

[0321] }

[0322] function getCase(uint256 seqOfMotion,uint attitude)external viewreturns(Case memory c){

[0323] c=_repo.boxes[seqOfMotion].cases[attitude];

[0324] }

[0325] function getBallot(uint256 seqOfMotion,address acct)external viewreturns(Ballot memory b){

[0326] b=_repo.boxes[seqOfMotion].ballots[acct];

[0327] }

[0328] Document Register It is a version control register contract used to categorize and record the addresses of different version contracts. It also inherits from the routing control contract, ensuring that only the manager contract has the right to call its write operation functions.

[0329] / / RegisterOfDocs.sol

[0330] pragma solidity^0.8.8;

[0331] import". / ShareholdersAgreement.sol";

[0332] import". / RegisterOfShares.sol";

[0333] import". / RegisterOfMembers.sol";

[0334] import". / GeneralMeetingMinutes.sol";

[0335] import ". / RouteControl.sol";

[0336] / / The document register contract is used to categorize and record the addresses of different versions of the register contract and shareholder agreements.

[0337] / / Including their current active versions and historical versions.

[0338] contract RegisterOfDocs is RouteControl{

[0339] enum TypeOfDoc{

[0340] ZeroPoint,

[0341] Shareholders Agreement

[0342] RegisterOfShares,

[0343] RegisterOfMembers,

[0344] General Meeting Minutes

[0345] KeeperOfBoox

[0346] }

[0347] struct Repo{

[0348] mapping(address=>bool)isDoc;

[0349] address[]addrList;

[0350] address pointer;

[0351] }

[0352] / / typeOfDoc=>Repo

[0353] mapping(uint=>Repo)private_repos;

[0354] constructor(address keeper)RouteControl(keeper){}

[0355] function regDoc(uint typeOfDoc,address body)external onlyKeeper{

[0356] Repo storage repo=_repos[typeOfDoc];

[0357] if(!repo.isDoc[body]){

[0358] repo.isDoc[body]=true;

[0359] repo.addrList.push(body);

[0360] }

[0361] }

[0362] function activateDoc(uint typeOfDoc,address body)external onlyKeeper{

[0363] Repo storage repo=_repos[typeOfDoc];

[0364] require(repo.isDoc[body],"doc not registered");

[0365] repo.pointer=body;

[0366] }

[0367] function isDoc(uint typeOfDoc,address body)external view returns(bool){

[0368] return_repos[typeOfDoc].isDoc[body];

[0369] }

[0370] function getDoc(uint typeOfDoc,uint seq)external view returns(address){

[0371] return_repos[typeOfDoc].addrList[seq];

[0372] }

[0373] function getActiveDoc(uint typeOfDoc)external view returns(address){

[0374] return_repos[typeOfDoc].pointer;

[0375] }

[0376] function getSHA()external view returns(ShareholdersAgreement){

[0377] return ShareholdersAgreement(_repos[uint8(TypeOfDoc.ShareholdersAgreement)].pointer);

[0378] }

[0379] function getROS()external view returns(RegisterOfShares){

[0380] return RegisterOfShares(_repos[uint8(TypeOfDoc.RegisterOfShares)].pointer);

[0381] }

[0382] function getROM()external view returns(RegisterOfMembers){

[0383] return RegisterOfMembers(_repos[uint8(TypeOfDoc.RegisterOfMembers)].pointer);

[0384] }

[0385] function getGMM()external view returns(GeneralMeetingMinutes){

[0386] return GeneralMeetingMinutes(_repos[uint8(TypeOfDoc.GeneralMeetingMinutes)].pointer);

[0387] }

[0388] }

[0389] Shareholder Agreement It is a code of conduct contract used to define the company's general governance rules and voting rules. These rules are stored as byte32 arrays and then parsed into structured data objects when read.

[0390] To ensure that only authorized accounts can edit rules, the shareholder agreement inherits a special access control contract called "Editing Rights Control." The account deploying the contract is assigned the "Lawyer" role, and only lawyers can invoke the "Add Rule" and "Delete Rule" write operation functions. Lawyers can transfer their role to another account. Upon finalization, lawyers can transfer their role to a zero address, ensuring that no account can then modify the rules.

[0391] / / ShareholdersAgreement.sol

[0392] pragma solidity^0.8.8;

[0393] / / DraftControl is an inheritable smart contract used for management

[0394] / / SHA sets access control permissions for rule functions.

[0395] contract DraftControl{

[0396] address private_attorney;

[0397] modifier onlyAttorney(){

[0398] require(msg.sender==_attorney,"msgSender is not attorney");

[0399] _;

[0400] }

[0401] constructor(){

[0402] _attorney = msg.sender;

[0403] }

[0404] function setAttorney(address_newAttorney)external onlyAttorney{

[0405] _attorney = _newAttorney;

[0406] }

[0407] function getAttorney()public view returns(address){

[0408] return_attorney;

[0409] }

[0410] }

[0411] / / SHA is a static parameter used to record rules for legal actions.

[0412] contract ShareholdersAgreement is DraftControl{

[0413] enum SeqOfRule{

[0414] Governance Rule

[0415] VR4SHA

[0416] }

[0417] / / seq=>rule

[0418] mapping(uint256=>bytes32)private_rules;

[0419] constructor()DraftControl(){}

[0420] function addRule(bytes32 rule) external onlyAttorney {

[0421] uint seqOfRule = uint16(uint(rule) >> 240);

[0422] _rules[seqOfRule] = rule;

[0423] }

[0424] function removeRule(uint256 seq) external onlyAttorney {

[0425] delete _rules[seq];

[0426] }

[0427] function getRule(uint256 seq) external view returns (bytes32) {

[0428] return _rules[seq];

[0429] }

[0430] / / ==== Voting Rules ====

[0431] struct VotingRule {

[0432] uint16 seqOfRule;

[0433] uint16 ratio;

[0434] uint16 invExitDays;

[0435] uint16 votePrepareDays;

[0436] uint16 votingDays;

[0437] }

[0438] function votingRuleParser(bytes32 sn) public pure returns (VotingRule memory rule) {

[0439] uint_sn = uint(sn);

[0440] rule = VotingRule({

[0441] seqOfRule: uint16(_sn >> 240),

[0442] ratio: uint16(_sn >> 224),

[0443] invExitDays: uint16(_sn >> 208),

[0444] votePrepareDays: uint16(_sn >> 192),

[0445] votingDays: uint16(_sn >> 176)

[0446] });

[0447] }

[0448] / / === General Governance Rules ===

[0449] struct GovernanceRule {

[0450] uint16 seqOfRule;

[0451] uint16 proposeWeightRatioOfGM;

[0452] }

[0453] function governanceRuleParser(bytes32 sn) public pure returns (GovernanceRule memory rule) {

[0454] uint_sn = uint(sn);

[0455] rule = GovernanceRule({

[0456] seqOfRule: uint16(_sn >> 240),

[0457] proposeWeightRatioOfGM: uint16(_sn >> 224)

[0458] });

[0459] }

[0460] }

[0461] Management Contract It defines and controls the precondition verification and legal outcome implementation for various legal actions. It also inherits from the routing control contract, ensuring that its configuration and initialization functions can only be called by specific external accounts. After system configuration and initialization, this external account can transfer its administrator role to address zero, thereby fixing the system configuration and initialization state.

[0462] / / KeeperOfBoox.sol

[0463] pragma solidity^0.8.8;

[0464] import". / RegisterOfMembers.sol";

[0465] import". / RegisterOfShares.sol";

[0466] import". / RegisterOfDocs.sol";

[0467] import". / ShareholdersAgreement.sol";

[0468] import ". / RouteControl.sol";

[0469] / / The bookkeeping management contract is used to define and control the conditions, procedures, and exercise of legal acts.

[0470] / / result.

[0471] contract KeeperOfBoox is RouteControl{

[0472] RegisterOfDocs private_rod;

[0473] constructor(address keeper)RouteControl(keeper){}

[0474] / / ====Initialize and configure the system====

[0475] / / Set the document register contract address for easy retrieval at runtime.

[0476] / / Examples of other register agreements and shareholder agreements.

[0477] function setROD(address rod)external onlyKeeper{

[0478] _rod = RegisterOfDocs(rod);

[0479] }

[0480] / / Initialize the company's shareholding structure.

[0481] function issueShare(address shareholder,uint amount,uint price)external onlyKeeper{

[0482] RegisterOfMembers_rom=_rod.getROM();

[0483] if(!_rom.isMember(shareholder)){

[0484] _rom.addMember(shareholder);

[0485] }

[0486] RegisterOfShares_ros=_rod.getROS();

[0487] uint seqOfShare=_ros.issueShare(shareholder,amount,price);

[0488] _rom.addShareToMember(seqOfShare,shareholder);

[0489] }

[0490] / / A shareholder creates a motion to approve a new version of the shareholders' agreement.

[0491] function createMotionToApproveSHA(address addrOfSHA)external{

[0492] / / Get a sample of the shareholder register.

[0493] RegisterOfMembers_rom=_rod.getROM();

[0494] Access control and authentication:

[0495] / / The caller should be a shareholder of the company.

[0496] require(_rom.isMember(msg.sender),"calleris not member");

[0497] / / Get a sample of the shareholders' meeting minutes.

[0498] GeneralMeetingMinutes_gmm=_rod.getGMM();

[0499] / / Operations to achieve legal outcomes:

[0500] / / Create a motion to approve the new version of the shareholders' agreement.

[0501] _gmm.createMotionToApproveDoc(addrOfSHA,

[0502] uint8(ShareholdersAgreement.SeqOfRule.VR4SHA));

[0503] / / Operations to achieve legal outcomes:

[0504] / / Register the address of the new version of the shareholders' agreement in the document register.

[0505] _rod.regDoc(uint8(RegisterOfDocs.TypeOfDoc.ShareholdersAgreement),addrOfSHA);

[0506] }

[0507] / / Submit a motion to the shareholders' meeting for approval.

[0508] function proposeMotionToGeneralMeeting(uint256 seqOfMotion,uint256seqOfVR)external{

[0509] / / Get a sample of the shareholder register.

[0510] RegisterOfMembers_rom=_rod.getROM();

[0511] / / Access control and authentication:

[0512] / / The caller should be a company shareholder.

[0513] require(_rom.isMember(msg.sender),"calleris not member");

[0514] / / Get a shareholder agreement instance.

[0515] ShareholdersAgreement_sha=_rod.getSHA();

[0516] / / Obtain and parse governance rules from a shareholder agreement instance.

[0517] ShareholdersAgreement.GovernanceRule memory gr=_sha.governanceRuleParser(

[0518] _sha.getRule(uint8(ShareholdersAgreement.SeqOfRule.GovernanceRule)) );

[0520] / / Get a sample share register contract.

[0521] RegisterOfShares_ros=_rod.getROS();

[0522] / / Get the caller's voting points.

[0523] uint votes=_getVotesOfMember(msg.sender,_rom,_ros);

[0524] / / Obtain the total number of voting rights in the company.

[0525] uint totalVotes=_ros.getTotalAmount();

[0526] / / Legal logic control detection:

[0527] / / The caller's voting weight should be greater than or equal to

[0528] / / Introduction requirements for submitting motions to the minutes of the shareholders' meeting.

[0529] require(totalVotes*gr.proposeWeightRatioOfGM<=votes*10000,

[0530] "proposer's voting power is not enough");

[0531] / / Get a contract example of the shareholders' meeting minutes.

[0532] GeneralMeetingMinutes_gmm=_rod.getGMM();

[0533] / / Get voting rules.

[0534] ShareholdersAgreement.VotingRule memory vr=_sha.votingRuleParser(

[0535] _sha.getRule(seqOfVR) );

[0537] / / Operations to achieve legal outcomes:

[0538] / / Update the status of the motion to "Proposed".

[0539] _gmm.proposeMotionToGeneralMeeting(seqOfMotion,msg.sender,vr);

[0540] }

[0541] function_getVotesOfMember(

[0542] address acct,RegisterOfMembers_rom,RegisterOfShares_ros

[0543] )private view returns(uint votes){

[0544] uint[]memory shares=_rom.getSharesOfMember(acct);

[0545] uintlen = shares.length;

[0546] while(len>0){

[0547] votes+=_ros.getShare(shares[len-1]).amount;

[0548] len--;

[0549] }

[0550] }

[0551] / / Vote for specific motions at the shareholders' meeting.

[0552] function castVote(uint256 seqOfMotion,uint attitude,bytes32 sigHash)external{

[0553] / / Obtain a shareholder register contract example.

[0554] RegisterOfMembers_rom=_rod.getROM();

[0555] / / Access control and authentication:

[0556] / / Voters must be shareholders of the company.

[0557] require(_rom.isMember(msg.sender),"acct not Member");

[0558] / / Get a contract example of the shareholders' meeting minutes.

[0559] GeneralMeetingMinutes_gmm=_rod.getGMM();

[0560] / / Get the target motion instance.

[0561] GeneralMeetingMinutes.Motion memory motion=_gmm.getMotion(seqOfMotion);

[0562] / / Time condition detection:

[0563] / / The current time should be within the voting window of the motion.

[0564] require(block.timestamp>=motion.body.voteStartDate,"vote not startedyet");

[0565] require(block.timestamp <motion.body.voteEndDate,"vote alreadyended");

[0566] / / Legal logic condition check:

[0567] / / The status of the motion should be "proposed".

[0568] require(motion.body.state==uint8(GeneralMeetingMinutes.StateOfMotion.Proposed),

[0569] "wrong state of Motion";

[0570] / / Get a sample share register contract.

[0571] RegisterOfShares_ros=_rod.getROS();

[0572] / / Get the caller's voting points.

[0573] uint votes=_getVotesOfMember(msg.sender,_rom,_ros);

[0574] / / Operations to achieve legal outcomes:

[0575] / / Records the attitude and voting points of a specific bidder toward the motion in question.

[0576] _gmm.castVote(seqOfMotion,attitude,sigHash,msg.sender,votes);

[0577] }

[0578] / / Calculate the voting results for a specific motion.

[0579] function voteCounting(uint256 seqOfMotion)external{

[0580] / / Get a contract example of the shareholders' meeting minutes.

[0581] GeneralMeetingMinutes_gmm=_rod.getGMM();

[0582] / / Get an instance of a specific motion.

[0583] GeneralMeetingMinutes.Motion memory motion=_gmm.getMotion(seqOfMotion);

[0584] / / Time limit condition detection:

[0585] The voting should have already concluded.

[0586] require(block.timestamp>=motion.body.voteEndDate,"vote not endedyet");

[0587] / / Legal logic control test:

[0588] / / The status of the motion should be "proposed".

[0589] require(motion.body.state==uint8(GeneralMeetingMinutes.StateOfMotion.Proposed),

[0590] "wrong state of Motion";

[0591] / / Obtain an instance of the shareholder agreement contract.

[0592] ShareholdersAgreement_sha=_rod.getSHA();

[0593] / / Voting rules for obtaining approval of the shareholders' agreement.

[0594] ShareholdersAgreement.VotingRule memory vr=

[0595] _sha.votingRuleParser(_sha.getRule(motion.head.seqOfVR));

[0596] / / An example of obtaining a share register agreement.

[0597] RegisterOfShares_ros=_rod.getROS();

[0598] / / Get all voting points of the company.

[0599] uint totalVotes=_ros.getTotalAmount();

[0600] / / Operations to achieve legal outcomes:

[0601] / / Calculate the voting results and record them in the minutes of the shareholders' meeting.

[0602] _gmm.voteCounting(seqOfMotion,vr,totalVotes);

[0603] }

[0604] / / Activate the shareholder agreement that has been approved by vote.

[0605] function activateSHA(address addrOfSHA,uint seqOfMotion)external{

[0606] / / Example of a shareholder register contract.

[0607] RegisterOfMembers_rom=_rod.getROM();

[0608] / / Access control and authentication:

[0609] / / The caller should be a shareholder of the company.

[0610] require(_rom.isMember(msg.sender),"acct not Member");

[0611] / / Obtain shareholder meeting minutes and contract examples.

[0612] GeneralMeetingMinutes_gmm=_rod.getGMM();

[0613] / / Get an instance of the target motion.

[0614] GeneralMeetingMinutes.Motion memory motion=_gmm.getMotion(seqOfMotion);

[0615] / / Access control and authentication:

[0616] / / The caller should be the proposer of the motion in question.

[0617] require(motion.head.proposer==msg.sender,"acct not proposer");

[0618] / / Verification of legal logic constraints:

[0619] / / The status of the motion should be "passed".

[0620] require(motion.body.state==uint8(GeneralMeetingMinutes.StateOfMotion.Passed),

[0621] "motion not passed";

[0622] / / Verification of legal logic constraints:

[0623] / / The content of the motion should point to the contract address of the new version of the shareholders' agreement.

[0624] require(motion.contents==uint(uint160(addrOfSHA)), "contents ofMotion is not about the SHA");

[0625] / / Verification of legal logic constraints:

[0626] The new version of the shareholders' agreement should not have been activated yet.

[0627] Require(addrOfSHA!=_rod.getActiveDoc(uint8 (RegisterOfDocs.TypeOfDoc.ShareholdersAgreement)),

[0628] "Sha has already been activated";

[0629] / / Operations to achieve legal outcomes:

[0630] / / Update the legal status of the shareholders' agreement to "activated".

[0631] _rod.activateDoc(uint8(RegisterOfDocs.TypeOfDoc.ShareholdersAgreement),addrOfSHA);

[0632] / / Operations to achieve legal outcomes:

[0633] / / Change the legal proceedings status of the motion in question to "executed".

[0634] _gmm.executeMotion(seqOfMotion);

[0635] }

[0636] }

[0637] To demonstrate the deployment, configuration, and initialization process of this system, as well as the operational steps of the automatic bookkeeping method, a test script using JS and the Hardhat framework is provided below, with embedded comments detailing the purpose of each operational step.

[0638] / / deployAndTest.js

[0639] / / Run the following command in the console: npx hardhat run . / deployAndTest.js

[0640] const hre=require("hardhat");

[0641] async function deployTool(signer,targetName,libraries,params){

[0642] let options={signer:signer};

[0643] if (libraries != undefined) {

[0644] options.libraries=libraries;

[0645] }

[0646] const Target=await hre.ethers.getContractFactory(targetName,options);

[0647] const target=await Target.deploy(...params);

[0648] await target.deployed();

[0649] console.log("Deployed",targetName,"at address:",target.address,"\n");

[0650] return target;

[0651] };

[0652] async function main(){

[0653] const signers = await hre.ethers.getSigners();

[0654] console.log("Deploying the contracts with the account:", await signers[0].getAddress());

[0655] const addrOfKeeper = await signers[1].getAddress();

[0656] console.log('Addr of Keeper:', addrOfKeeper);

[0657] const AddrZero = '0x00'.padEnd(42, '0');

[0658] const HashZero = '0x00'.padEnd(66, '0');

[0659] / / ==== Deploy system smart contracts ====

[0660] let libraries = {};

[0661] let params = [];

[0662] let res;

[0663] const sha = await deployTool(signers[0], "ShareholdersAgreement", libraries, params);

[0664] params = [addrOfKeeper];

[0665] const ros = await deployTool(signers[0], "RegisterOfShares", libraries, params);

[0666] const rom = await deployTool(signers[0], "RegisterOfMembers", libraries, params);

[0667] const gmm=await deployTool(signers[0],"GeneralMeetingMinutes",libraries,params);

[0668] const rod=await deployTool(signers[0],"RegisterOfDocs",libraries,params);

[0669] const kob=await deployTool(signers[0],"KeeperOfBoox",libraries,params);

[0670] / / ====Setting the Rules for the Shareholder Agreement====

[0671] / / Add general governance rules to the shareholders' agreement.

[0672] let rule='0x000003e8'; / / Hex'03e8'equal to Decimal'1000';

[0673] rule = rule.padEnd(66, '0');

[0674] await sha.addRule(rule);

[0675] res = await sha.getRule(0);

[0676] res=await sha.governanceRuleParser(res);

[0677] console.log('input GovernmentRule:',res);

[0678] / / Add voting rules to the shareholders agreement to approve the new version of the shareholders agreement.

[0679] rule='0x00011a0b000100000003'; / / Hex'1a0b'equal to Decimal'6667';

[0680] rule = rule.padEnd(66, '0');

[0681] await sha.addRule(rule);

[0682] res = await sha.getRule(1);

[0683] res=await sha.votingRuleParser(res);

[0684] console.log('input VotingRule:',res);

[0685] / / The role of lawyer was transferred to "zero address" to solidify the content of the shareholder agreement.

[0686] await sha.setAttorney(AddrZero);

[0687] res=await sha.getAttorney();

[0688] console.log('Attorney of SHA removed:',res);

[0689] / / ====Register the addresses of each register agreement and shareholders' agreement in the document register agreement====

[0690] await rod.connect(signers[1]).regDoc(1,sha.address);

[0691] await rod.connect(signers[1]).regDoc(2,ros.address);

[0692] await rod.connect(signers[1]).regDoc(3,rom.address);

[0693] await rod.connect(signers[1]).regDoc(4,gmm.address);

[0694] await rod.connect(signers[1]).regDoc(5,kob.address);

[0695] await rod.connect(signers[1]).activateDoc(1,sha.address);

[0696] await rod.connect(signers[1]).activateDoc(2,ros.address);

[0697] await rod.connect(signers[1]).activateDoc(3,rom.address);

[0698] await rod.connect(signers[1]).activateDoc(4,gmm.address);

[0699] await rod.connect(signers[1]).activateDoc(5,kob.address);

[0700] / / ==== Set the administrator contract as the administrator of each register contract ====

[0701] await ros.connect(signers[1]).setKeeper(kob.address);

[0702] res = await ros.getKeeper();

[0703] console.log('keeper of ROS:', res);

[0704] await rom.connect(signers[1]).setKeeper(kob.address);

[0705] res = await rom.getKeeper();

[0706] console.log('keeper of ROM:', res);

[0707] await gmm.connect(signers[1]).setKeeper(kob.address);

[0708] res = await gmm.getKeeper();

[0709] console.log('keeper of GMM:', res);

[0710] await rod.connect(signers[1]).setKeeper(kob.address);

[0711] res=await rod.getKeeper();

[0712] console.log('keeper of ROD:',res);

[0713] / / ====Initialize the Manager Contract====

[0714] / / ----Set Document Register Contract Address----

[0715] await kob.connect(signers[1]).setROD(rod.address);

[0716] / / ----Issuance of equity to establish the initial equity structure----

[0717] await kob.connect(signers[1]).issueShare(await signers[0].getAddress(),5000000,100);

[0718] res=await ros.getShare(1);

[0719] console.log('input Share_1:',res);

[0720] await kob.connect(signers[1]).issueShare(await signers[1].getAddress(),4000000,100);

[0721] res=await ros.getShare(2);

[0722] console.log('input Share_2:',res);

[0723] await kob.connect(signers[1]).issueShare(await signers[2].getAddress(),3000000,150);

[0724] res=await ros.getShare(3);

[0725] console.log('input Share_3:',res);

[0726] await kob.connect(signers[1]).issueShare(await signers[0].getAddress(),1000000,200);

[0727] res=await ros.getShare(4);

[0728] console.log('input Share_4:',res);

[0729] / / Transfer the manager role of the manager contract to the zero address to fix the system configuration and initial state.

[0730] await kob.connect(signers[1]).setKeeper(AddrZero);

[0731] res=await kob.getKeeper();

[0732] console.log('Keeper of KOB removed:',res);

[0733] / / ---Displays the system initialization status for verification----

[0734] res=await ros.getTotalAmount();

[0735] console.log('TotalAmount:',res);

[0736] res=await rom.getSharesOfMember(signers[0].address);

[0737] console.log('Shares of Member_1:',res);

[0738] res=await rom.getSharesOfMember(signers[1].address);

[0739] console.log('Shares of Member_2:',res);

[0740] res=await rom.getSharesOfMember(signers[2].address);

[0741] console.log('Shares of Member_3:',res);

[0742] / / ====Testing Legal Acts====

[0743] / / ---Drafting a new version of the shareholders' agreement---

[0744] params = [];

[0745] const sha_1=await deployTool(signers[0],"ShareholdersAgreement",libraries,params);

[0746] / / Set general governance rules.

[0747] rule = '0x000003e8';

[0748] rule = rule.padEnd(66, '0');

[0749] await sha_1.addRule(rule);

[0750] res=await sha_1.getRule(0);

[0751] res=await sha_1.governanceRuleParser(res);

[0752] console.log('input GovernmentRule:',res);

[0753] / / Set the voting rules that must be followed to approve the new version of the shareholders' agreement.

[0754] rule = '0x00011388000100000003'; / / Hexadecimal number '1388' equals decimal number '5000';

[0755] rule = rule.padEnd(66, '0');

[0756] await sha_1.addRule(rule);

[0757] res=await sha_1.getRule(1);

[0758] res=await sha_1.votingRuleParser(res);

[0759] console.log('input VotingRule:',res);

[0760] / / Transfer the lawyer role to a zero address to solidify the content of the shareholder agreement.

[0761] await sha_1.setAttorney(AddrZero);

[0762] res=await sha_1.getAttorney();

[0763] console.log('Attorney of SHA removed as:',res);

[0764] / / Create a motion to approve the new version of the shareholders' agreement.

[0765] await kob.createMotionToApproveSHA(sha_1.address);

[0766] / / Submit a motion to the shareholders' meeting to consider and vote on the new version of the shareholders' agreement.

[0767] await kob.proposeMotionToGeneralMeeting(1,1);

[0768] / / On-chain time fast forward function.

[0769] const now = async() => {

[0770] return(await hre.ethers.provider.getBlock()).timestamp;

[0771] }

[0772] constincreaseTime=async(seconds)=>{

[0773] await hre.ethers.provider.send("evm_increaseTime",[seconds]);

[0774] await hre.ethers.provider.send("evm_mine");

[0775] console.log('Forward On-Chain time for',seconds,'seconds\n');

[0776] console.log('Current On-Chain Date:',parseTimestamp(await now()),'\n');

[0777] }

[0778] function parseTimestamp(stamp){

[0779] return(new Date(stamp*1000)).toISOString();

[0780] }

[0781] / / Fast forward the on-chain time by 2 days.

[0782] awaitincreaseTime(86400*2);

[0783] / / User_1 voted in favor of the motion.

[0784] await kob.castVote(1,1,HashZero);

[0785] res=await gmm.getBallot(1,signers[0].address);

[0786] console.log('Member_1cast vote:',res);

[0787] / / User_2 voted in favor of the motion.

[0788] await kob.connect(signers[1]).castVote(1,1,HashZero);

[0789] res=await gmm.getBallot(1,signers[1].address);

[0790] console.log('Member_2cast vote:',res);

[0791] / / User_3 voted against the motion.

[0792] await kob.connect(signers[2]).castVote(1,2,HashZero);

[0793] res=await gmm.getBallot(1,signers[2].address);

[0794] console.log('Member_3cast vote:',res);

[0795] / / Fast forward the on-chain time by 3 days.

[0796] awaitincreaseTime(86400*3);

[0797] / / User_1 tallies the voting results.

[0798] await kob.voteCounting(1);

[0799] res=await gmm.getMotion(1);

[0800] console.log('vote result:',res);

[0801] User _1 activates the new version of the Shareholder Agreement.

[0802] await kob.activateSHA(sha_1.address,1);

[0803] / / Verify the contract address of the currently valid shareholder agreement.

[0804] res = await rod.getSHA();

[0805] console.log('Actived SHA_1:',res);

[0806] };

[0807] main()

[0808] .then(()=>process.exit(0))

[0809] .catch((error)=>{

[0810] console.error(error);

[0811] process.exit(1);

[0812] });

Claims

1. An automated bookkeeping system for assets and legal transactions based on blockchain technology, comprising the following smart contracts:

1. Multiple registry smart contracts, each configured as follows: (1) Define and record specific data objects that represent the status of legal rights or the content of legal acts; (2) Receive instructions from authorized address accounts to create, update, or delete the aforementioned data objects; and (3) Automatically respond to query requests for the above data objects.

2. A behavior specification smart contract is configured as follows: (1) Define and record the static parameters of the rules governing relevant legal acts; (2) Receive instructions from authorized address accounts to create, update, and delete the above rule parameters; and (3) Automatically respond to query requests for these rule parameters.

3. Multiple manager smart contracts, each configured as follows: (1) Define the preconditions for a specific legal act, including: a) Access control restrictions based on the account address on which the instruction was issued; b) Time-based constraints based on the current block timestamp; as well as c) Legal and logical restrictions based on the attribute values ​​of specific data objects. (2) Verify the above preconditions using the following process and algorithm: a) Query the rule parameter values ​​of the query behavior specification, the current block timestamp, and the attribute values ​​of related data objects; b) Execute an algorithm to determine whether all the above preconditions have been met; as well as c) If any condition is not met, return an error message. (3) Call specific functions of a specific register smart contract to create, update, or delete data objects containing specific legal rights status or legal acts in order to perform legal acts.

2. The register contract of claim 1 further includes a version-controlled register contract configured to: (1) Maintain and record: a) The addresses of different versions of the smart contract; and b) The legal validity status of the aforementioned smart contract version; (2) Receive instructions from authorized address accounts to create, update, or delete contract addresses and legal status; and (3) Automatically respond to query requests for different versions of contract addresses and their legal validity status.

3. A method for automating bookkeeping of assets and legal transactions using the system described in claim 1, comprising the following steps:

1. The manager's smart contract receives a function call instruction to initiate a specific legal act; 2. The administrator's smart contract verifies whether all the preconditions for this specific legal act have been met through the following steps: (1) Obtain the rule parameter values ​​that regulate this specific legal act; (2) Obtain the specific attribute values ​​of the relevant data objects; (3) Obtain the current block timestamp; and (4) Use the command to send the account address, query the rule parameter value, data object attribute value, and current block timestamp, and execute the verification algorithm to verify whether all conditions are met one by one.

3. If any precondition is not met, the process terminates and an error message is returned.

4. If all preconditions are met, the administrator's smart contract calls the relevant functions of the specific register smart contract to create, update, or delete specific data objects, thereby recording the legal act.

4. The legal act described in claim 3 further includes:

1. Create a new smart contract: Once all preconditions are met, the manager smart contract will: (1) Create a new smart contract; and (2) Call the version control contract and record the address of the new contract according to its category; 2. Smart Contract Version Validity: Once all preconditions are met, the manager's smart contract will: (1) Invoke the version control contract to mark a specific smart contract as the currently valid version; and (2) Update the legal validity status of the old version of the contract to invalid.