当前位置:网站首页>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
边栏推荐
- 【深度之眼吴恩达机器学习作业班第四期】逻辑回归编程实现
- js:Array.reduce累加计算、合并数组
- How to share the virtual environment of pycharm to jupyter Lab
- [eye of depth wuenda machine learning operation class phase IV] logic regression programming implementation
- Audio and video development cases 99 lectures - Contents
- C#导入csv到mysql数据库中
- [Kerberos] analysis of Kerberos authentication
- Simulation time and bag operation in ROS
- SVM,人脸识别遇到的问题及解决方法
- What does Ali's 211 mean?
猜你喜欢

Robotframework learning notes: introduction to robot framework and browserlibrary (playwright)

穿越过后,她说多元宇宙真的存在

产品经理应该学习墨刀还是Axure?

Talking about Nacos configuration center from Nacos client

AI deep dive of Huawei cloud

code::blocks代码格式化快捷键

C actual combat - high configuration version of Snake game design

【深度之眼吴恩达机器学习作业班第四期】Regularization正则化总结

Vulnhub's dc9 target

线段树以及使用
随机推荐
Hook 简介
互联网公司的组织结构与产品经理岗位职责是什么?
反思 - 完美主义
Qtcreator set character set
[eye of depth wuenda machine learning homework class phase IV] regularization regularization summary
进程通信 - 管道
基础知识 - 语法标准(ANSI C、ISO C、GNU C)
Handle series - install spotbugs and use them quickly
Oracle batch insert data - insert ethnic data
[quantitative investment system] problem records and Solutions
C # import CSV into MySQL database
[quantitative investment system]django realizes screening and paging from the database
MySQL system keyword summary (official website)
征文投稿丨使用轻量应用服务器搭建博客环境
Electric check code configuration
Django - installing mysqlclient error: mysqlclient 1.4.0 or newer is required; you have 0.9.3
Explanation of swing transformer theory
After crossing, she said that the multiverse really exists
[Kerberos] analysis of Kerberos authentication
Common MySQL errors and solutions summarized painstakingly (I)