当前位置:网站首页>Solidity deploy and validate agent contracts
Solidity deploy and validate agent contracts
2022-06-29 08:09:00 【【03】】
Related contracts
Use openzeppelin Two agency ancillary contracts
TransparentUpgradeableProxy.sol
Address
openzeppelin-contracts/contracts/proxy/transparent at master · OpenZeppelin/openzeppelin-contracts
Deploy logical contract
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract Web03{
constructor() public {
}
string public constant url = 'web03.cn';
mapping (uint => string) public names;
uint public namesN;
function addName(string memory _name) public {
names[namesN++] = _name;
}
}
Trading address :
https://rinkeby.etherscan.io/tx/0xd11215fa054742276d378917b76093b51dd74124735d8bfffe14928f25d0fc07
Contract address :0xd37C4f32816Ac29a839ca2a854726432080D14c4
Deployment management contract ProxyAdmin.sol
pragma solidity ^0.8.0;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/proxy/transparent/ProxyAdmin.sol";
contract Web03ProxyAdmin is ProxyAdmin{
constructor() {
}
}
Trading address :https://rinkeby.etherscan.io/tx/0xfabbdfb4fc9a0c0196a04d3fd1bfceafc23cc78e0351155a71415b37b91bd4b2
Contract address :0x60db1202a8c2d2b60d628a03741fed1920bf25f2
Deployment agent contract TransparentUpgradeableProxy.sol
pragma solidity ^0.8.0;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
contract Web03Proxy is TransparentUpgradeableProxy{
constructor(address _logic,address admin_,bytes memory _data) TransparentUpgradeableProxy(_logic, admin_, _data){
}
}
Argument parsing
- address _logic Logical contract address 【0xd37C4f32816Ac29a839ca2a854726432080D14c4】
- address admin_ Management contract address 【0x60db1202a8c2d2b60d628a03741fed1920bf25f2】
- bytes memory _data Parameter bytecode when publishing logical contract ,0x No parameter 【0x】
Trading address :https://rinkeby.etherscan.io/tx/0xbeb7bf1cae9b8c37035fd251080baefb9fb1d9d72c5498997685c2a429af1318
Contract address :0x82f4728Aa261eBd7887367096BCA4C15356CF188
Verify contract
In order to see the visual effect , Select the validation contract
Please check previous articles on how to verify 《solidity Contract validation 》:https://web03.cn/blog/299
After verification, the blockchain browser cannot see the method of logical contract in the proxy contract ?
stay Code tab choice More Option Re selection Is this a proxy?

He will automatically find your logical contract , Click on Verify that will do

Upgrade contract
- Call contract storage data , Pre validate proxy data -
Call the proxy contract first to verify the proxy function
call addName, Add a set of data

here ,names Methods can also be found

1、 Release new logical contracts
contract Web03V2{
constructor() {
}
string public constant url = 'web03.cn';
mapping (uint => string) public names;
uint public namesN;
uint public constant D = 1;
function addName(string memory _name) public {
names[namesN++] = _name;
}
function addD(uint _d) public pure{
D + _d;
}
}
Trading address :https://rinkeby.etherscan.io/tx/0x887c2d2a5f7ebdf1c1b27902a7a03b3cb4da87102797a941909b93c595b09cbb
Contract address :0xdFEaA297C19622892a07e4Da428b377aDA10f0AD
2、 Call the upgrade method
Call the management contract method
- upgrade, Need to ( Agency contract address , New logical contract address )
- upgradeAndCall, Need to ( Agency contract address , New logical contract address , Initialize call data , Pay the amount )
The current upgrade does not involve initialization data and payment amount , So call upgrade that will do
upgrade(0x82f4728Aa261eBd7887367096BCA4C15356CF188, 0xdFEaA297C19622892a07e4Da428b377aDA10f0AD)
Upgrade transaction address :https://rinkeby.etherscan.io/tx/0x9de289d9a3fb021cdb04fa08301a706c3a7e1b52da5aa5c9f13cfb812c775a9f
- After upgrading , View and verify data -

You can see , The new method of adding to the upgraded contract D And methods addD All have appeared (addD Writing mistakes , Ignore , But it doesn't affect )
Inquire about names[0]= zero three
The data before the upgrade is still preserved , It means that the agent is successful
- There is a proxy contract for the data , This data is initialized when the agent is deployed , Later, only the logical address was changed ,SO The data is always stored
边栏推荐
- Process communication - Pipeline
- PHP 7.1.13 版本,在使用过程中发现 浮点类型 数据经过 json_encode 之后会出现精度问题
- After crossing, she said that the multiverse really exists
- Mongodb- connect to the database using the mongo/mongosh command line
- [quantitative investment system]django realizes screening and paging from the database
- Up and down transitions in polymorphism
- js异或混淆代码
- SQL Server enable CDC
- 在iframe标签中操作外层dom
- Hook introduction
猜你喜欢

Explanation of swing transformer theory

Mongodb- connect to the database using the mongo/mongosh command line

PostgreSQL installation: the database cluster initialization failed, stack hbuilder installation

MySQL系统关键字汇总(官网)

Linear regression with one variable

ROS当中的仿真时间以及Bag包操作

线段树以及使用

1284_FreeRTOS任务优先级获取实现分析

Explain the garbage collection mechanism (GC) in JVM
![[eye of depth Wu Enda's fourth operation class] summary of multiple linear regression with multiple variables](/img/51/581be1bdfe7cc97193ff68d3ec5d22.png)
[eye of depth Wu Enda's fourth operation class] summary of multiple linear regression with multiple variables
随机推荐
Audio and video development cases 99 lectures - Contents
js:Array. Reduce cumulative calculation and array consolidation
Explain the garbage collection mechanism (GC) in JVM
[quantitative investment system] factor processing and installation Talib
【深度之眼吴恩达第四期作业班】多元线性回归Linear Regression with multiple variables总结
Line features & surface features of vSLAM features
Friends, static keywords, static methods, and relationships between objects
Process communication - Pipeline
NOR flash application layer operation
JS XOR obfuscation code
JS to implement a detailed scheme for lazy loading of pictures (it can be used after being imported)
Binary search tree
How to share the virtual environment of pycharm to jupyter Lab
服装产业发展趋势|供应链|智能制造
AI deep dive of Huawei cloud
MySQL system keyword summary (official website)
《动手学深度学习》(一)-- 线性神经网络
À propos de Hook
PHP 7.1.13 版本,在使用过程中发现 浮点类型 数据经过 json_encode 之后会出现精度问题
Codeforces Round #799 (Div. 4)