Transactions
Internal Transactions
Coin Balance History
Logs
Code
Read Contract
Read Proxy
Write Contract
Write Proxy
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- TokenProxy
- Optimization enabled
- true
- Compiler version
- v0.4.24+commit.e67f0147
- Optimization runs
- 10
- EVM Version
- default
- Verified at
- 2022-08-11T20:54:31.096627Z
Constructor Arguments
000000000000000000000000769aed9d3f34f320010fa31cd04fe3bad8700033000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000001544616920537461626c65636f696e20284350584429000000000000000000000000000000000000000000000000000000000000000000000000000000000000084441492e43505844000000000000000000000000000000000000000000000000
Arg [0] (address) : 0x769aed9d3f34f320010fa31cd04fe3bad8700033
Arg [1] (string) : Dai Stablecoin (CPXD)
Arg [2] (string) : DAI.CPXD
Arg [3] (uint8) : 18
Contract source code
// Sources flattened with hardhat v2.9.1 https://hardhat.org
// File openzeppelin-solidity/contracts/[email protected]
pragma solidity ^0.4.24;
/**
* Utility library of inline functions on addresses
*/
library AddressUtils {
/**
* Returns whether the target address is a contract
* @dev This function will return false if invoked during the constructor of a contract,
* as the code is not actually created until after the constructor finishes.
* @param _addr address to check
* @return whether the target address is a contract
*/
function isContract(address _addr) internal view returns (bool) {
uint256 size;
// XXX Currently there is no better way to check if there is a contract in an address
// than to check the size of the code at that address.
// See https://ethereum.stackexchange.com/a/14016/36603
// for more details about how this works.
// TODO Check this again before the Serenity release, because all addresses will be
// contracts then.
// solium-disable-next-line security/no-inline-assembly
assembly { size := extcodesize(_addr) }
return size > 0;
}
}
// File contracts/upgradeability/Proxy.sol
pragma solidity 0.4.24;
/**
* @title Proxy
* @dev Gives the possibility to delegate any call to a foreign implementation.
*/
contract Proxy {
/**
* @dev Tells the address of the implementation where every call will be delegated.
* @return address of the implementation to which it will be delegated
*/
/* solcov ignore next */
function implementation() public view returns (address);
/**
* @dev Fallback function allowing to perform a delegatecall to the given implementation.
* This function will return whatever the implementation call returns
*/
function() public payable {
// solhint-disable-previous-line no-complex-fallback
address _impl = implementation();
require(AddressUtils.isContract(_impl));
assembly {
/*
0x40 is the "free memory slot", meaning a pointer to next slot of empty memory. mload(0x40)
loads the data in the free memory slot, so `ptr` is a pointer to the next slot of empty
memory. It's needed because we're going to write the return data of delegatecall to the
free memory slot.
*/
let ptr := mload(0x40)
/*
`calldatacopy` is copy calldatasize bytes from calldata
First argument is the destination to which data is copied(ptr)
Second argument specifies the start position of the copied data.
Since calldata is sort of its own unique location in memory,
0 doesn't refer to 0 in memory or 0 in storage - it just refers to the zeroth byte of calldata.
That's always going to be the zeroth byte of the function selector.
Third argument, calldatasize, specifies how much data will be copied.
calldata is naturally calldatasize bytes long (same thing as msg.data.length)
*/
calldatacopy(ptr, 0, calldatasize)
/*
delegatecall params explained:
gas: the amount of gas to provide for the call. `gas` is an Opcode that gives
us the amount of gas still available to execution
_impl: address of the contract to delegate to
ptr: to pass copied data
calldatasize: loads the size of `bytes memory data`, same as msg.data.length
0, 0: These are for the `out` and `outsize` params. Because the output could be dynamic,
these are set to 0, 0 so the output data will not be written to memory. The output
data will be read using `returndatasize` and `returdatacopy` instead.
result: This will be 0 if the call fails and 1 if it succeeds
*/
let result := delegatecall(gas, _impl, ptr, calldatasize, 0, 0)
/*
*/
/*
ptr current points to the value stored at 0x40,
because we assigned it like ptr := mload(0x40).
Because we use 0x40 as a free memory pointer,
we want to make sure that the next time we want to allocate memory,
we aren't overwriting anything important.
So, by adding ptr and returndatasize,
we get a memory location beyond the end of the data we will be copying to ptr.
We place this in at 0x40, and any reads from 0x40 will now read from free memory
*/
mstore(0x40, add(ptr, returndatasize))
/*
`returndatacopy` is an Opcode that copies the last return data to a slot. `ptr` is the
slot it will copy to, 0 means copy from the beginning of the return data, and size is
the amount of data to copy.
`returndatasize` is an Opcode that gives us the size of the last return data. In this case, that is the size of the data returned from delegatecall
*/
returndatacopy(ptr, 0, returndatasize)
/*
if `result` is 0, revert.
if `result` is 1, return `size` amount of data from `ptr`. This is the data that was
copied to `ptr` from the delegatecall return data
*/
switch result
case 0 {
revert(ptr, returndatasize)
}
default {
return(ptr, returndatasize)
}
}
}
}
// File contracts/interfaces/IBridgeMediator.sol
pragma solidity 0.4.24;
interface IBridgeMediator {
function tokenImage() public view returns (address);
}
// File contracts/upgradeable_contracts/multi_amb_erc20_to_erc677/TokenProxy.sol
pragma solidity 0.4.24;
/**
* @title TokenProxy
* @dev Helps to reduces the size of the deployed bytecode for automatically created tokens, by using a proxy contract.
*/
contract TokenProxy is Proxy {
bytes4 internal constant INITIALIZE = 0x1624f6c6; // bytes4(keccak256("initialize(string,string,uint8)"))
/**
* @dev Creates an upgradeable token proxy for PermittableToken.sol, initializes its storage by using delegatecall
* @param _name token name.
* @param _symbol token symbol.
*/
constructor(address _tokenImage, string _name, string _symbol, uint8 _decimals) public {
bool result = _tokenImage.delegatecall(abi.encodeWithSelector(INITIALIZE, _name, _symbol, _decimals));
require(result, "failed to initialize token storage");
}
/**
* @dev Retrieves the implementation contract address, mirrored token image.
* @return token image address.
*/
function implementation() public view returns (address) {
return IBridgeMediator(bridgeContractAddr()).tokenImage();
}
function bridgeContractAddr() public view returns (address _bridgeContractAddr) {
// The bridge contract is stored at address slot 7. It needs to be read from the storage because it's initialized
// by the initialize function using delegatecall in the constructor.
// It has to be stored in slot 7 to maintain compatibility with legacy bridged tokens on-chain.
// Ideally it would be stored at a slot like keccak256("bridgeContractAddr"), which could
// still work for newly deployed proxies but would leave the possibility of old proxies
// getting out of sync, so this compromise was chosen to minimise complexity and keep the
// bridge contract address stored in a single known slot.
// The population of slot 7 is tested explicitly in bridged_tokens.test.js
assembly {
_bridgeContractAddr := sload(0x07)
}
}
}
Contract ABI
[{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":""}],"name":"implementation","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"_bridgeContractAddr"}],"name":"bridgeContractAddr","inputs":[],"constant":true},{"type":"constructor","stateMutability":"nonpayable","payable":false,"inputs":[{"type":"address","name":"_tokenImage"},{"type":"string","name":"_name"},{"type":"string","name":"_symbol"},{"type":"uint8","name":"_decimals"}]},{"type":"fallback","stateMutability":"payable","payable":true}]
Contract Creation Code
0x608060405234801561001057600080fd5b5060405161042438038061042483398101604081815282516020808501519285015160608087015160ff81166064880152602487019182529487018051608488015280519497909692019493600093600160a060020a038916937f1624f6c600000000000000000000000000000000000000000000000000000000938993899389938392604482019260a4909201918801908083838e5b838110156100bf5781810151838201526020016100a7565b50505050905090810190601f1680156100ec5780820380516001836020036101000a031916815260200191505b50838103825285518152855160209182019187019080838360005b8381101561011f578181015183820152602001610107565b50505050905090810190601f16801561014c5780820380516001836020036101000a031916815260200191505b5060408051601f19818403018152918152602082018051600160e060020a03167fffffffff00000000000000000000000000000000000000000000000000000000909a169990991789525181519198909750879650945092508291508490508360005b838110156101c75781810151838201526020016101af565b50505050905090810190601f1680156101f45780820380516001836020036101000a031916815260200191505b50915050600060405180830381855af49250505080151561029c57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f6661696c656420746f20696e697469616c697a6520746f6b656e2073746f726160448201527f6765000000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b5050505050610174806102b06000396000f3006080604052600436106100325763ffffffff60e060020a6000350416635c60da1b811461007c57806361ab8ffd146100ad575b600061003c6100c2565b90506100478161013a565b151561005257600080fd5b60405136600082376000803683855af43d82016040523d6000833e808015610078573d83f35b3d83fd5b34801561008857600080fd5b506100916100c2565b60408051600160a060020a039092168252519081900360200190f35b3480156100b957600080fd5b50610091610142565b60006100cc610142565b600160a060020a031663c1aef4f26040518163ffffffff1660e060020a028152600401602060405180830381600087803b15801561010957600080fd5b505af115801561011d573d6000803e3d6000fd5b505050506040513d602081101561013357600080fd5b5051905090565b6000903b1190565b600754905600a165627a7a72305820678b6f35e9957d2a9fee62ec076439b1aff9d87c4e87e911d09ff7a0a8d4f4900029000000000000000000000000769aed9d3f34f320010fa31cd04fe3bad8700033000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000001544616920537461626c65636f696e20284350584429000000000000000000000000000000000000000000000000000000000000000000000000000000000000084441492e43505844000000000000000000000000000000000000000000000000
Deployed ByteCode
0x6080604052600436106100325763ffffffff60e060020a6000350416635c60da1b811461007c57806361ab8ffd146100ad575b600061003c6100c2565b90506100478161013a565b151561005257600080fd5b60405136600082376000803683855af43d82016040523d6000833e808015610078573d83f35b3d83fd5b34801561008857600080fd5b506100916100c2565b60408051600160a060020a039092168252519081900360200190f35b3480156100b957600080fd5b50610091610142565b60006100cc610142565b600160a060020a031663c1aef4f26040518163ffffffff1660e060020a028152600401602060405180830381600087803b15801561010957600080fd5b505af115801561011d573d6000803e3d6000fd5b505050506040513d602081101561013357600080fd5b5051905090565b6000903b1190565b600754905600a165627a7a72305820678b6f35e9957d2a9fee62ec076439b1aff9d87c4e87e911d09ff7a0a8d4f4900029