ITPub博客

首页 > 区块链 > 区块链 > 关于TRX波场DAPP模式系统开发技术方案(程序逻辑)

关于TRX波场DAPP模式系统开发技术方案(程序逻辑)

原创 区块链 作者:Tg_StPv888 时间:2023-02-22 10:08:35 0 删除 编辑

  智能合约与区块链的结合形成了智能合约法规自动执行系统,该系统有三个重要的原则:

  首先,智能合约数据来源于链上。这是指智能合约的输入是从区块链的 数据库里面出来的。这些数据是由区块链保证的,具有真实难以篡改的特征。

  其次,智能合约的执行在链上。这是指智能合约是在多个节点上面执行,而所执行的结果必须是相同,智能合约所出的结果一定要被共识才能被接受。

  再者,智能合约输出在链上。这是指智能合约的输出结果必须存在区块链上面,这样保证结果的真实与可追溯性,并且为其他相衔接的智能合约提供输入数据的准确性保障。

  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博客 ” ,链接:https://blog.itpub.net/70016646/viewspace-2936349/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
专业区块项目开发团队:18028578624微電

注册时间:2022-04-13

  • 博文量
    158
  • 访问量
    95703