關於TRX波場DAPP模式系統開發技術方案(程式邏輯)

Tg_StPv888發表於2023-02-22

  智慧合約與區塊鏈的結合形成了智慧合約法規自動執行系統,該系統有三個重要的原則:

  首先,智慧合約資料來源於鏈上。這是指智慧合約的輸入是從區塊鏈的 裡面出來的。這些資料是由區塊鏈保證的,具有真實難以篡改的特徵。

  其次,智慧合約的執行在鏈上。這是指智慧合約是在多個節點上面執行,而所執行的結果必須是相同,智慧合約所出的結果一定要被共識才能被接受。

  再者,智慧合約輸出在鏈上。這是指智慧合約的輸出結果必須存在區塊鏈上面,這樣保證結果的真實與可追溯性,並且為其他相銜接的智慧合約提供輸入資料的準確性保障。

  File 1 of 4: OwnedUpgradeabilityProxy.sol

pragma solidity ^0.4.24;

import './UpgradeabilityProxy.sol';

/**

  • @title OwnedUpgradeabilityProxy
  • @dev This contract combines an upgradeability proxy with basic authorization control functionalities

*/ contract OwnedUpgradeabilityProxy is UpgradeabilityProxy { /**

  • @dev Event to show ownership has been transferred
  • @param previousOwner representing the address of the previous owner
  • @param newOwner representing the address of the new owner

*/ event ProxyOwnershipTransferred(address previousOwner, address newOwner);

// Storage position of the owner of the contract bytes32 private constant proxyOwnerPosition = keccak256("org.zeppelinos.proxy.owner");

/**

  • @dev the constructor sets the original owner of the contract to the sender account.

*/ constructor() public {

setUpgradeabilityOwner(msg.sender);
複製

}

/**

  • @dev Throws if called by any account other than the owner.

*/ modifier onlyProxyOwner() {

require(msg.sender == proxyOwner());_;
複製

}

/**

  • @dev Tells the address of the owner
  • @return the address of the owner

*/ function proxyOwner() public view returns (address owner) {

bytes32 position = proxyOwnerPosition;assembly {
  owner := sload(position)}
複製

}

/**

  • @dev Sets the address of the owner

*/ function setUpgradeabilityOwner(address newProxyOwner) internal {

bytes32 position = proxyOwnerPosition;assembly {
  sstore(position, newProxyOwner)}
複製

}

/**

  • @dev Allows the current owner to transfer control of the contract to a newOwner.
  • @param newOwner The address to transfer ownership to.

*/ function transferProxyOwnership(address newOwner) public onlyProxyOwner {

require(newOwner != address(0));emit ProxyOwnershipTransferred(proxyOwner(), newOwner);setUpgradeabilityOwner(newOwner);
複製

}

/**

  • @dev Allows the proxy owner to upgrade the current version of the proxy.
  • @param implementation representing the address of the new implementation to be set.

*/ function upgradeTo(address implementation) public onlyProxyOwner {

_upgradeTo(implementation);
複製

}

/**

  • @dev Allows the proxy owner to upgrade the current version of the proxy and call the new implementation
  • to initialize whatever is needed through a low level call.
  • @param implementation representing the address of the new implementation to be set.
  • @param data represents the msg.data to bet sent in the low level call. This parameter may include the function
  • signature of the implementation to be called with the needed payload

*/ function upgradeToAndCall(address implementation, bytes data) payable public onlyProxyOwner {

upgradeTo(implementation);require(implementation.delegatecall(data));
複製

}


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/70016646/viewspace-2936349/,如需轉載,請註明出處,否則將追究法律責任。

相關文章