Skip to content

Instantly share code, notes, and snippets.

View flyq's full-sized avatar
⚙️
Make Etherem Great Again

liquan.eth flyq

⚙️
Make Etherem Great Again
View GitHub Profile

Upgradeability using Unstructured Storage

测试

  1. 在 Ropsten 测试网上, 地址 0xbd70d89667A3E1bD341AC235259c5f2dDE8172A9 部署了 OwnedUpgradeabilityProxy 合约于 0xf78aa080f84513203f37019c255f78cfc390b62d tx 链接
  2. 地址 0xbd70d89667A3E1bD341AC235259c5f2dDE8172A9 部署了 Token_V0 合约于 0xa347821506065054b4ccad798125e1005b154b53 tx 链接
  3. 用地址 0xbd70d89667A3E1bD341AC235259c5f2dDE8172A9 调用 OwnedUpgradeabilityProxy 合约的 upgradeTo 函数,参数是 0xa347821506065054b4ccad798125e1005b154b53, 即 Token_V0 合约。
  4. 用 Proxy 合约地址 0xf78aa080f84513203f37019c255f78cfc390b62d 实例化一个 Token_V0 合约,然后调用初始化函数 initialize()。 这样直接调用 Proxy.mint() 等等就会 delegatecall 转而调用 Token_V0 地址所在的 Token_V0 合约里面的函数。比如这里我调用 Proxy.mint(owner, 1000),成功执行。

升级

pragma solidity ^0.4.18;
import './Token_V0.sol';
import './Ownable.sol';
/**
* @title Token_V1
* @dev Version 1 of a token to show upgradeability.
* The idea here is to extend a token behaviour providing mintable token functionalities
* in addition to what's provided in version 0
[
{
"u_i": "7b38225091fe0fc3868b1a18a083388f55f638dd039bdf61d2ed215f033a21ba",
"y_i": {
"x": "408d196c54f796150feaf144665d0b5cb2030bf2706fc23d50506977edfe9fa7",
"y": "9fcf4791869c3bee37ce23f4d6eda1f3039f15d47c5126ddf11298b5bf4f2177"
},
"dk": {
"p": "115523320621418856194291062266208292930517491704835285308590110074912913155015133279669955322094416666157687881381847546903588429997417918514194620287583496354537562647801611986255957498428090028836683084211501636500333998978141722412626620973752334265111289163997231937313085816871899604550386724292750357727",
"q": "158660861360373067640950191148490034535647923366920801942486640032234539917408539205143535120646108347368594391986258990306833782838115402106123644663574795852525480428198530724251141471227559551562956318766790784760238170847431634502156499165282165352924911332861516716048625619966827777851878512363827744471"
@flyq
flyq / test.rs
Last active April 10, 2020 11:06
#[macro_use]
extern crate diesel;
#[macro_use]
extern crate serde_derive;
use actix_identity::{CookieIdentityPolicy, IdentityService};
use actix_web::{middleware, web, App, HttpServer};
use diesel::prelude::*;
use diesel::r2d2::{self, ConnectionManager};
This post links my 3Box profile to my Github account! Web3 social profiles by 3Box.
✅ did:3:bafyreibsvgkzvll2obewolt6ddrxpj4wb4pwvsz4agldamgrm3j446jwz4 ✅
Create your profile today to start building social connection and trust online at https://3Box.io/
Verifying my Blockstack ID is secured with the address 1Hj89vg2gpLXwWzLRJPsiVKvDo75GrJ8cT https://explorer.blockstack.org/address/1Hj89vg2gpLXwWzLRJPsiVKvDo75GrJ8cT
Verifying my Blockstack ID is secured with the address 1Hj89vg2gpLXwWzLRJPsiVKvDo75GrJ8cT https://explorer.blockstack.org/address/1Hj89vg2gpLXwWzLRJPsiVKvDo75GrJ8cT
#!/usr/bin/env bash
COLOR_WHITE=$(tput setaf 7);
COLOR_MAGENTA=$(tput setaf 5);
FONT_BOLD=$(tput bold);
FONT_NORMAL=$(tput sgr0);
echo
echo -e "$COLOR_WHITE $FONT_BOLD Substrate Node Template Setup $FONT_NORMAL";
@flyq
flyq / substrate.sh
Last active December 18, 2019 14:51
#!/usr/bin/env bash
COLOR_WHITE=$(tput setaf 7);
COLOR_MAGENTA=$(tput setaf 5);
FONT_BOLD=$(tput bold);
FONT_NORMAL=$(tput sgr0);
echo
echo -e "$COLOR_WHITE $FONT_BOLD Substrate Node Template Setup $FONT_NORMAL";
@flyq
flyq / Mondrian.sol
Last active September 3, 2019 05:07
Mondrian ERC721 Token 智能合约
/**
*Submitted for verification at Etherscan.io on 2019-09-03
*/
pragma solidity ^0.5.11;
/**
* @title Owned
*/