Research Article
A Four-Tier Smart Contract Model with On-Chain Upgrade
Algorithm 1
Contract on-chain upgrade algorithm.
| Input: | | contractAddr | | userAddr | | userId | | operation | | Output: | | bool | (1) | Begin | (2) | Role ← invokeUserContract (userAddr, userId) | (3) | If (!verifyAuthority (role, operation)) | (4) | return false | (5) | ValidationContractInstance ← loadValidationContract () | (6) | If (!verifyContract (validationContractInstance, contractAddr)) | (7) | return false | (8) | ProxyContractInstance ← loadProxyContract() | (9) | UpdateInfo ← updateContractAddr (proxyContractInstance, contractAddr, operation) | (10) | DestroyInfo ← destroyOldContract() | (11) | If (!save (updateInfo, destroyInfo)) | (12) | return false | (13) | return true | (14) | End |
|