diff --git a/packages/website/.gitignore b/packages/website/.gitignore index add48429c6..b2d6de3062 100644 --- a/packages/website/.gitignore +++ b/packages/website/.gitignore @@ -18,7 +18,3 @@ npm-debug.log* yarn-debug.log* yarn-error.log* - -# Documentation drafts -drafts -smart-contracts diff --git a/packages/website/docs/intro.md b/packages/website/docs/intro.md deleted file mode 100644 index c589156a66..0000000000 --- a/packages/website/docs/intro.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -sidebar_position: 1 ---- - -# Getting started - -Welcome to Taiko! 🥁 - -## Learning materials - -The best places to start learning about Taiko would be: - -- [FAQ](../faq/) -- [Introduction to Taiko](https://mirror.xyz/labs.taiko.eth/oRy3ZZ_4-6IEQcuLCMMlxvdH6E-T3_H7UwYVzGDsgf4) -- [The Type 1 ZK-EVM](https://mirror.xyz/labs.taiko.eth/w7NSKDeKfJoEy0p89I9feixKfdK-20JgWF9HZzxfeBo) -- [Whitepaper](https://taikoxyz.github.io/taiko-mono/taiko-whitepaper.pdf) -- [GitHub](https://github.com/taikoxyz/) diff --git a/packages/website/docs/intro/_category_.json b/packages/website/docs/intro/_category_.json new file mode 100644 index 0000000000..18d2f31916 --- /dev/null +++ b/packages/website/docs/intro/_category_.json @@ -0,0 +1,7 @@ +{ + "label": "Introduction", + "collapsed": false, + "link": { + "type": "generated-index" + } +} diff --git a/packages/website/docs/intro/index.md b/packages/website/docs/intro/index.md new file mode 100644 index 0000000000..7bb6274333 --- /dev/null +++ b/packages/website/docs/intro/index.md @@ -0,0 +1,27 @@ +--- +sidebar_position: 1 +--- + +# Quickstart + +Welcome to Taiko! 🥁 + +## Learn about Taiko + +Here are the best places to learn about Taiko. + +### Overview + +- [Introduction to Taiko](https://mirror.xyz/labs.taiko.eth/oRy3ZZ_4-6IEQcuLCMMlxvdH6E-T3_H7UwYVzGDsgf4) +- [The Type 1 ZK-EVM](https://mirror.xyz/labs.taiko.eth/w7NSKDeKfJoEy0p89I9feixKfdK-20JgWF9HZzxfeBo) +- [Whitepaper](https://taikoxyz.github.io/taiko-mono/taiko-whitepaper.pdf) +- [Contract documentation](/docs/category/smart-contracts/) +- [Frequently Asked Questions (FAQ)](/faq/) + +### Follow us + +- [Blog](https://mirror.xyz/labs.taiko.eth) +- [Discord](https://discord.gg/taikoxyz) +- [GitHub](https://github.com/taikoxyz/) +- [Reddit](https://www.reddit.com/r/taiko_xyz/) +- [Twitter](https://twitter.com/taikoxyz) diff --git a/packages/website/docs/reference/smart-contracts/L1/TaikoL1.md b/packages/website/docs/reference/smart-contracts/L1/TaikoL1.md new file mode 100644 index 0000000000..34624912bb --- /dev/null +++ b/packages/website/docs/reference/smart-contracts/L1/TaikoL1.md @@ -0,0 +1,263 @@ +## TaikoL1 + +### state + +```solidity +struct LibData.State state +``` + +### tentative + +```solidity +struct LibData.TentativeState tentative +``` + +### \_\_gap + +```solidity +uint256[50] __gap +``` + +### init + +```solidity +function init(address _addressManager, bytes32 _genesisBlockHash) external +``` + +### commitBlock + +```solidity +function commitBlock(uint64 commitSlot, bytes32 commitHash) external +``` + +Write a _commit hash_ so a few blocks later a L2 block can be proposed +such that `calculateCommitHash(meta.beneficiary, meta.txListHash)` equals +to this commit hash. + +#### Parameters + +| Name | Type | Description | +| ---------- | ------- | --------------------------------------------------------------------------- | +| commitSlot | uint64 | A slot to save this commit. Slot 0 will always be reset to zero for refund. | +| commitHash | bytes32 | Calculated with: `calculateCommitHash(beneficiary, txListHash)`. | + +### proposeBlock + +```solidity +function proposeBlock(bytes[] inputs) external +``` + +Propose a Taiko L2 block. + +#### Parameters + +| Name | Type | Description | +| ------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| inputs | bytes[] | A list of data input: - inputs[0] is abi-encoded BlockMetadata that the actual L2 block header must satisfy. Note the following fields in the provided meta object must be zeros -- their actual values will be provisioned by Ethereum. - id - l1Height - l1Hash - mixHash - timestamp - inputs[1] is a list of transactions in this block, encoded with RLP. Note, in the corresponding L2 block an _anchor transaction_ will be the first transaction in the block -- if there are n transactions in `txList`, then there will be up to n+1 transactions in the L2 block. | + +### proveBlock + +```solidity +function proveBlock(uint256 blockId, bytes[] inputs) external +``` + +Prove a block is valid with a zero-knowledge proof, a transaction +merkel proof, and a receipt merkel proof. + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| blockId | uint256 | The index of the block to prove. This is also used to select the right implementation version. | +| inputs | bytes[] | A list of data input: - inputs[0] is an abi-encoded object with various information regarding the block to be proven and the actual proofs. - inputs[1] is the actual anchor transaction in this L2 block. Note that the anchor transaction is always the first transaction in the block. - inputs[2] is the receipt of the anchor transaction. | + +### proveBlockInvalid + +```solidity +function proveBlockInvalid(uint256 blockId, bytes[] inputs) external +``` + +Prove a block is invalid with a zero-knowledge proof and a receipt +merkel proof. + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| blockId | uint256 | The index of the block to prove. This is also used to select the right implementation version. | +| inputs | bytes[] | A list of data input: - inputs[0] An Evidence object with various information regarding the block to be proven and the actual proofs. - inputs[1] The target block to be proven invalid. - inputs[2] The receipt for the `invalidBlock` transaction on L2. Note that the `invalidBlock` transaction is supposed to be the only transaction in the L2 block. | + +### verifyBlocks + +```solidity +function verifyBlocks(uint256 maxBlocks) external +``` + +Verify up to N blocks. + +#### Parameters + +| Name | Type | Description | +| --------- | ------- | ------------------------------- | +| maxBlocks | uint256 | Max number of blocks to verify. | + +### enableWhitelisting + +```solidity +function enableWhitelisting(bool whitelistProposers, bool whitelistProvers) public +``` + +Enable or disable proposer and prover whitelisting + +#### Parameters + +| Name | Type | Description | +| ------------------ | ---- | ------------------------------------- | +| whitelistProposers | bool | True to enable proposer whitelisting. | +| whitelistProvers | bool | True to enable prover whitelisting. | + +### whitelistProposer + +```solidity +function whitelistProposer(address proposer, bool whitelisted) public +``` + +Add or remove a proposer from the whitelist. + +#### Parameters + +| Name | Type | Description | +| ----------- | ------- | ------------------------------------ | +| proposer | address | The proposer to be added or removed. | +| whitelisted | bool | True to add; remove otherwise. | + +### whitelistProver + +```solidity +function whitelistProver(address prover, bool whitelisted) public +``` + +Add or remove a prover from the whitelist. + +#### Parameters + +| Name | Type | Description | +| ----------- | ------- | ---------------------------------- | +| prover | address | The prover to be added or removed. | +| whitelisted | bool | True to add; remove otherwise. | + +### halt + +```solidity +function halt(bool toHalt) public +``` + +Halt or resume the chain. + +#### Parameters + +| Name | Type | Description | +| ------ | ---- | ------------------------------ | +| toHalt | bool | True to halt, false to resume. | + +### isProposerWhitelisted + +```solidity +function isProposerWhitelisted(address proposer) public view returns (bool) +``` + +Check whether a proposer is whitelisted. + +#### Parameters + +| Name | Type | Description | +| -------- | ------- | ------------- | +| proposer | address | The proposer. | + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------------------------------------------------- | +| [0] | bool | True if the proposer is whitelisted, false otherwise. | + +### isProverWhitelisted + +```solidity +function isProverWhitelisted(address prover) public view returns (bool) +``` + +Check whether a prover is whitelisted. + +#### Parameters + +| Name | Type | Description | +| ------ | ------- | ----------- | +| prover | address | The prover. | + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | --------------------------------------------------- | +| [0] | bool | True if the prover is whitelisted, false otherwise. | + +### isHalted + +```solidity +function isHalted() public view returns (bool) +``` + +Check if the L1 is halted. + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | -------------------------------- | +| [0] | bool | True if halted, false otherwise. | + +### isCommitValid + +```solidity +function isCommitValid(uint256 commitSlot, uint256 commitHeight, bytes32 commitHash) public view returns (bool) +``` + +### getProposedBlock + +```solidity +function getProposedBlock(uint256 id) public view returns (struct LibData.ProposedBlock) +``` + +### getSyncedHeader + +```solidity +function getSyncedHeader(uint256 number) public view returns (bytes32) +``` + +### getLatestSyncedHeader + +```solidity +function getLatestSyncedHeader() public view returns (bytes32) +``` + +### getStateVariables + +```solidity +function getStateVariables() public view returns (uint64, uint64, uint64, uint64) +``` + +### signWithGoldenTouch + +```solidity +function signWithGoldenTouch(bytes32 hash, uint8 k) public view returns (uint8 v, uint256 r, uint256 s) +``` + +### getBlockProvers + +```solidity +function getBlockProvers(uint256 id, bytes32 parentHash) public view returns (address[]) +``` + +### getConstants + +```solidity +function getConstants() public pure returns (uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256) +``` diff --git a/packages/website/docs/reference/smart-contracts/L1/TkoToken.md b/packages/website/docs/reference/smart-contracts/L1/TkoToken.md new file mode 100644 index 0000000000..d71fc1fb00 --- /dev/null +++ b/packages/website/docs/reference/smart-contracts/L1/TkoToken.md @@ -0,0 +1,75 @@ +## TkoToken + +_This is Taiko's governance and fee token._ + +### \_\_gap + +```solidity +uint256[50] __gap +``` + +### Mint + +```solidity +event Mint(address account, uint256 amount) +``` + +### Burn + +```solidity +event Burn(address account, uint256 amount) +``` + +### init + +```solidity +function init(address _addressManager) external +``` + +_Initializer to be called after being deployed behind a proxy. +Based on our simulation in simulate/tokenomics/index.js, both +amountMintToDAO and amountMintToDev shall be set to ~150,000,000._ + +### transfer + +```solidity +function transfer(address to, uint256 amount) public returns (bool) +``` + +### transferFrom + +```solidity +function transferFrom(address from, address to, uint256 amount) public returns (bool) +``` + +### mint + +```solidity +function mint(address account, uint256 amount) public +``` + +_Mints tokens to the given address's balance. This will increase +the circulating supply._ + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | ---------------------------------- | +| account | address | The address to receive the tokens. | +| amount | uint256 | The amount of tokens to mint. | + +### burn + +```solidity +function burn(address account, uint256 amount) public +``` + +_Burn tokens from the given address's balance. This will decrease +the circulating supply._ + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | ------------------------------------ | +| account | address | The address to burn the tokens from. | +| amount | uint256 | The amount of tokens to burn. | diff --git a/packages/website/docs/reference/smart-contracts/L2/TaikoL2.md b/packages/website/docs/reference/smart-contracts/L2/TaikoL2.md new file mode 100644 index 0000000000..bf7ed0351e --- /dev/null +++ b/packages/website/docs/reference/smart-contracts/L2/TaikoL2.md @@ -0,0 +1,115 @@ +## TaikoL2 + +### l2Hashes + +```solidity +mapping(uint256 => bytes32) l2Hashes +``` + +### l1Hashes + +```solidity +mapping(uint256 => bytes32) l1Hashes +``` + +### publicInputHash + +```solidity +bytes32 publicInputHash +``` + +### latestSyncedHeader + +```solidity +bytes32 latestSyncedHeader +``` + +### \_\_gap + +```solidity +uint256[46] __gap +``` + +### BlockInvalidated + +```solidity +event BlockInvalidated(bytes32 txListHash) +``` + +### constructor + +```solidity +constructor(address _addressManager) public +``` + +### anchor + +```solidity +function anchor(uint256 l1Height, bytes32 l1Hash) external +``` + +Persist the latest L1 block height and hash to L2 for cross-layer +bridging. This function will also check certain block-level global +variables because they are not part of the Trie structure. + + Note that this transaction shall be the first transaction in every + L2 block. + +#### Parameters + +| Name | Type | Description | +| -------- | ------- | -------------------------------------------------------- | +| l1Height | uint256 | The latest L1 block height when this block was proposed. | +| l1Hash | bytes32 | The latest L1 block hash when this block was proposed. | + +### invalidateBlock + +```solidity +function invalidateBlock(bytes txList, enum LibInvalidTxList.Reason hint, uint256 txIdx) external +``` + +Invalidate a L2 block by verifying its txList is not intrinsically valid. + +#### Parameters + +| Name | Type | Description | +| ------ | ---------------------------- | ------------------------------------------------------------------------------------------------ | +| txList | bytes | The L2 block's txlist. | +| hint | enum LibInvalidTxList.Reason | A hint for this method to invalidate the txList. | +| txIdx | uint256 | If the hint is for a specific transaction in txList, txIdx specifies which transaction to check. | + +### getSyncedHeader + +```solidity +function getSyncedHeader(uint256 number) public view returns (bytes32) +``` + +### getLatestSyncedHeader + +```solidity +function getLatestSyncedHeader() public view returns (bytes32) +``` + +### getBlockHash + +```solidity +function getBlockHash(uint256 number) public view returns (bytes32) +``` + +### getConstants + +```solidity +function getConstants() public pure returns (uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256) +``` + +### \_checkPublicInputs + +```solidity +function _checkPublicInputs() private +``` + +### \_hashPublicInputs + +```solidity +function _hashPublicInputs(uint256 chainId, uint256 number, uint256 baseFee, bytes32[255] ancestors) private pure returns (bytes32) +``` diff --git a/packages/website/docs/reference/smart-contracts/_category_.json b/packages/website/docs/reference/smart-contracts/_category_.json new file mode 100644 index 0000000000..d33e5f152f --- /dev/null +++ b/packages/website/docs/reference/smart-contracts/_category_.json @@ -0,0 +1,7 @@ +{ + "label": "Smart contracts", + "collapsed": true, + "link": { + "type": "generated-index" + } +} diff --git a/packages/website/docs/reference/smart-contracts/bridge/Bridge.md b/packages/website/docs/reference/smart-contracts/bridge/Bridge.md new file mode 100644 index 0000000000..e463d1da05 --- /dev/null +++ b/packages/website/docs/reference/smart-contracts/bridge/Bridge.md @@ -0,0 +1,138 @@ +## Bridge + +Bridge contract which is deployed on both L1 and L2. Mostly a thin wrapper +which calls the library implementations. See {IBridge} for more details. + +_The code hash for the same address on L1 and L2 may be different._ + +### state + +```solidity +struct LibBridgeData.State state +``` + +### \_\_gap + +```solidity +uint256[50] __gap +``` + +### MessageStatusChanged + +```solidity +event MessageStatusChanged(bytes32 signal, enum LibBridgeData.MessageStatus status) +``` + +### DestChainEnabled + +```solidity +event DestChainEnabled(uint256 chainId, bool enabled) +``` + +### receive + +```solidity +receive() external payable +``` + +Allow Bridge to receive ETH from EtherVault. + +### init + +```solidity +function init(address _addressManager) external +``` + +_Initializer to be called after being deployed behind a proxy._ + +### sendMessage + +```solidity +function sendMessage(struct IBridge.Message message) external payable returns (bytes32 signal) +``` + +Sends a message to the destination chain and takes custody +of Ether required in this contract. All extra Ether will be refunded. + +### sendSignal + +```solidity +function sendSignal(bytes32 signal) external +``` + +Stores a signal on the bridge contract and emits an event for the +relayer to pick up. + +### processMessage + +```solidity +function processMessage(struct IBridge.Message message, bytes proof) external +``` + +### retryMessage + +```solidity +function retryMessage(struct IBridge.Message message, bool isLastAttempt) external +``` + +### enableDestChain + +```solidity +function enableDestChain(uint256 _chainId, bool enabled) external +``` + +### isMessageSent + +```solidity +function isMessageSent(bytes32 signal) public view virtual returns (bool) +``` + +Checks if a signal has been stored on the bridge contract by the +current address. + +### isMessageReceived + +```solidity +function isMessageReceived(bytes32 signal, uint256 srcChainId, bytes proof) public view virtual returns (bool) +``` + +Checks if a signal has been received on the destination chain and +sent by the src chain. + +### isSignalSent + +```solidity +function isSignalSent(address sender, bytes32 signal) public view virtual returns (bool) +``` + +Checks if a signal has been stored on the bridge contract by the +specified address. + +### isSignalReceived + +```solidity +function isSignalReceived(bytes32 signal, uint256 srcChainId, address sender, bytes proof) public view virtual returns (bool) +``` + +Check if a signal has been received on the destination chain and sent +by the specified sender. + +### getMessageStatus + +```solidity +function getMessageStatus(bytes32 signal) public view virtual returns (enum LibBridgeData.MessageStatus) +``` + +### context + +```solidity +function context() public view returns (struct IBridge.Context) +``` + +Returns the bridge state context. + +### isDestChainEnabled + +```solidity +function isDestChainEnabled(uint256 _chainId) public view returns (bool) +``` diff --git a/packages/website/docs/reference/smart-contracts/bridge/BridgedERC20.md b/packages/website/docs/reference/smart-contracts/bridge/BridgedERC20.md new file mode 100644 index 0000000000..c5d8c9767d --- /dev/null +++ b/packages/website/docs/reference/smart-contracts/bridge/BridgedERC20.md @@ -0,0 +1,79 @@ +## BridgedERC20 + +### srcToken + +```solidity +address srcToken +``` + +### srcChainId + +```solidity +uint256 srcChainId +``` + +### \_\_gap + +```solidity +uint256[48] __gap +``` + +### BridgeMint + +```solidity +event BridgeMint(address account, uint256 amount) +``` + +### BridgeBurn + +```solidity +event BridgeBurn(address account, uint256 amount) +``` + +### init + +```solidity +function init(address _addressManager, address _srcToken, uint256 _srcChainId, uint8 _decimals, string _symbol, string _name) external +``` + +_Initializer to be called after being deployed behind a proxy._ + +### bridgeMintTo + +```solidity +function bridgeMintTo(address account, uint256 amount) public +``` + +_only a TokenVault can call this function_ + +### bridgeBurnFrom + +```solidity +function bridgeBurnFrom(address account, uint256 amount) public +``` + +_only a TokenVault can call this function_ + +### transfer + +```solidity +function transfer(address to, uint256 amount) public returns (bool) +``` + +_any address can call this_ + +### transferFrom + +```solidity +function transferFrom(address from, address to, uint256 amount) public returns (bool) +``` + +_any address can call this_ + +### source + +```solidity +function source() public view returns (address, uint256) +``` + +_returns the srcToken being bridged and the srcChainId_ diff --git a/packages/website/docs/reference/smart-contracts/bridge/EtherVault.md b/packages/website/docs/reference/smart-contracts/bridge/EtherVault.md new file mode 100644 index 0000000000..b6696ec779 --- /dev/null +++ b/packages/website/docs/reference/smart-contracts/bridge/EtherVault.md @@ -0,0 +1,82 @@ +## EtherVault + +Vault that holds Ether. + +### authorizedAddrs + +```solidity +mapping(address => bool) authorizedAddrs +``` + +### \_\_gap + +```solidity +uint256[49] __gap +``` + +### Authorized + +```solidity +event Authorized(address addr, bool authorized) +``` + +### onlyAuthorized + +```solidity +modifier onlyAuthorized() +``` + +### receive + +```solidity +receive() external payable +``` + +### init + +```solidity +function init(address addressManager) external +``` + +### receiveEther + +```solidity +function receiveEther(uint256 amount) public +``` + +Send Ether from EtherVault to the sender, checking they are authorized. + +#### Parameters + +| Name | Type | Description | +| ------ | ------- | ------------------------ | +| amount | uint256 | Amount of ether to send. | + +### authorize + +```solidity +function authorize(address addr, bool authorized) public +``` + +Set the authorized status of an address, only the owner can call this. + +#### Parameters + +| Name | Type | Description | +| ---------- | ------- | ---------------------------------------- | +| addr | address | Address to set the authorized status of. | +| authorized | bool | Authorized status to set. | + +### isAuthorized + +```solidity +function isAuthorized(address addr) public view returns (bool) +``` + +Get the authorized status of an address. + +#### Parameters + +| Name | Type | Description | +| ---- | ------- | ---------------------------------------- | +| addr | address | Address to get the authorized status of. | diff --git a/packages/website/docs/reference/smart-contracts/bridge/IBridge.md b/packages/website/docs/reference/smart-contracts/bridge/IBridge.md new file mode 100644 index 0000000000..a1a9788f19 --- /dev/null +++ b/packages/website/docs/reference/smart-contracts/bridge/IBridge.md @@ -0,0 +1,111 @@ +## IBridge + +Bridge interface. + +_Cross-chain Ether is held by Bridges, not TokenVaults._ + +### Message + +```solidity +struct Message { + uint256 id; + address sender; + uint256 srcChainId; + uint256 destChainId; + address owner; + address to; + address refundAddress; + uint256 depositValue; + uint256 callValue; + uint256 processingFee; + uint256 gasLimit; + bytes data; + string memo; +} + +``` + +### Context + +```solidity +struct Context { + bytes32 signal; + address sender; + uint256 srcChainId; +} + +``` + +### SignalSent + +```solidity +event SignalSent(address sender, bytes32 signal) +``` + +### MessageSent + +```solidity +event MessageSent(bytes32 signal, struct IBridge.Message message) +``` + +### sendMessage + +```solidity +function sendMessage(struct IBridge.Message message) external payable returns (bytes32 signal) +``` + +Sends a message to the destination chain and takes custody +of Ether required in this contract. All extra Ether will be refunded. + +### sendSignal + +```solidity +function sendSignal(bytes32 signal) external +``` + +Stores a signal on the bridge contract and emits an event for the +relayer to pick up. + +### isMessageSent + +```solidity +function isMessageSent(bytes32 signal) external view returns (bool) +``` + +Checks if a signal has been stored on the bridge contract by the +current address. + +### isMessageReceived + +```solidity +function isMessageReceived(bytes32 signal, uint256 srcChainId, bytes proof) external view returns (bool) +``` + +Checks if a signal has been received on the destination chain and +sent by the src chain. + +### isSignalSent + +```solidity +function isSignalSent(address sender, bytes32 signal) external view returns (bool) +``` + +Checks if a signal has been stored on the bridge contract by the +specified address. + +### isSignalReceived + +```solidity +function isSignalReceived(bytes32 signal, uint256 srcChainId, address sender, bytes proof) external view returns (bool) +``` + +Check if a signal has been received on the destination chain and sent +by the specified sender. + +### context + +```solidity +function context() external view returns (struct IBridge.Context context) +``` + +Returns the bridge state context. diff --git a/packages/website/docs/reference/smart-contracts/bridge/TokenVault.md b/packages/website/docs/reference/smart-contracts/bridge/TokenVault.md new file mode 100644 index 0000000000..8841d2e771 --- /dev/null +++ b/packages/website/docs/reference/smart-contracts/bridge/TokenVault.md @@ -0,0 +1,154 @@ +## TokenVault + +This vault holds all ERC20 tokens (but not Ether) that users have deposited. +It also manages the mapping between canonical ERC20 tokens and their bridged +tokens. + +### CanonicalERC20 + +```solidity +struct CanonicalERC20 { + uint256 chainId; + address addr; + uint8 decimals; + string symbol; + string name; +} + +``` + +### isBridgedToken + +```solidity +mapping(address => bool) isBridgedToken +``` + +### bridgedToCanonical + +```solidity +mapping(address => struct TokenVault.CanonicalERC20) bridgedToCanonical +``` + +### canonicalToBridged + +```solidity +mapping(uint256 => mapping(address => address)) canonicalToBridged +``` + +### \_\_gap + +```solidity +uint256[47] __gap +``` + +### BridgedERC20Deployed + +```solidity +event BridgedERC20Deployed(uint256 srcChainId, address canonicalToken, address bridgedToken, string canonicalTokenSymbol, string canonicalTokenName, uint8 canonicalTokenDecimal) +``` + +### EtherSent + +```solidity +event EtherSent(address to, uint256 destChainId, uint256 amount, bytes32 signal) +``` + +### EtherReceived + +```solidity +event EtherReceived(address from, uint256 amount) +``` + +### ERC20Sent + +```solidity +event ERC20Sent(address to, uint256 destChainId, address token, uint256 amount, bytes32 signal) +``` + +### ERC20Received + +```solidity +event ERC20Received(address to, address from, uint256 srcChainId, address token, uint256 amount) +``` + +### init + +```solidity +function init(address addressManager) external +``` + +### sendEther + +```solidity +function sendEther(uint256 destChainId, address to, uint256 gasLimit, uint256 processingFee, address refundAddress, string memo) external payable +``` + +Transfers Ether to this vault and sends a message to the destination +chain so the user can receive Ether. + +_Ether is held by Bridges on L1 and by the EtherVault on L2, +not TokenVaults._ + +#### Parameters + +| Name | Type | Description | +| ------------- | ------- | ------------------------------------------------------ | +| destChainId | uint256 | The destination chain ID where the `to` address lives. | +| to | address | The destination address. | +| gasLimit | uint256 | | +| processingFee | uint256 | @custom:see Bridge | +| refundAddress | address | | +| memo | string | | + +### sendERC20 + +```solidity +function sendERC20(uint256 destChainId, address to, address token, uint256 amount, uint256 gasLimit, uint256 processingFee, address refundAddress, string memo) external payable +``` + +Transfers ERC20 tokens to this vault and sends a message to the +destination chain so the user can receive the same amount of tokens +by invoking the message call. + +#### Parameters + +| Name | Type | Description | +| ------------- | ------- | ------------------------------------------------------------------------------------------------------------ | +| destChainId | uint256 | The destination chain ID where the `to` address lives. | +| to | address | The destination address. | +| token | address | The address of the token to be sent. | +| amount | uint256 | The amount of token to be transferred. | +| gasLimit | uint256 | @custom:see Bridge | +| processingFee | uint256 | @custom:see Bridge | +| refundAddress | address | The fee refund address. If this address is address(0), extra fees will be refunded back to the `to` address. | +| memo | string | | + +### receiveERC20 + +```solidity +function receiveERC20(struct TokenVault.CanonicalERC20 canonicalToken, address from, address to, uint256 amount) external +``` + +_This function can only be called by the bridge contract while +invoking a message call._ + +#### Parameters + +| Name | Type | Description | +| -------------- | -------------------------------- | -------------------------------------------------------------------------------------------------------------------- | +| canonicalToken | struct TokenVault.CanonicalERC20 | The canonical ERC20 token which may or may not live on this chain. If not, a BridgedERC20 contract will be deployed. | +| from | address | The source address. | +| to | address | The destination address. | +| amount | uint256 | The amount of tokens to be sent. 0 is a valid value. | + +### \_getOrDeployBridgedToken + +```solidity +function _getOrDeployBridgedToken(struct TokenVault.CanonicalERC20 canonicalToken) private returns (address) +``` + +### \_deployBridgedToken + +```solidity +function _deployBridgedToken(struct TokenVault.CanonicalERC20 canonicalToken) private returns (address bridgedToken) +``` diff --git a/packages/website/docs/reference/smart-contracts/common/AddressResolver.md b/packages/website/docs/reference/smart-contracts/common/AddressResolver.md new file mode 100644 index 0000000000..1d84900aa8 --- /dev/null +++ b/packages/website/docs/reference/smart-contracts/common/AddressResolver.md @@ -0,0 +1,99 @@ +## AddressResolver + +This abstract contract provides a name-to-address lookup. Under the hood, +it uses an AddressManager to manage the name-to-address mapping. + +### \_addressManager + +```solidity +contract IAddressManager _addressManager +``` + +### \_\_gap + +```solidity +uint256[49] __gap +``` + +### onlyFromNamed + +```solidity +modifier onlyFromNamed(string name) +``` + +### onlyFromNamedEither + +```solidity +modifier onlyFromNamedEither(string name1, string name2) +``` + +### resolve + +```solidity +function resolve(string name) public view virtual returns (address payable) +``` + +Resolves a name to an address on the current chain. + +_This function will throw if the resolved address is `address(0)`._ + +#### Parameters + +| Name | Type | Description | +| ---- | ------ | -------------------- | +| name | string | The name to resolve. | + +#### Return Values + +| Name | Type | Description | +| ---- | --------------- | --------------------------------- | +| [0] | address payable | The name's corresponding address. | + +### resolve + +```solidity +function resolve(uint256 chainId, string name) public view virtual returns (address payable) +``` + +Resolves a name to an address on the specified chain. + +_This function will throw if the resolved address is `address(0)`._ + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | -------------------- | +| chainId | uint256 | The chainId. | +| name | string | The name to resolve. | + +#### Return Values + +| Name | Type | Description | +| ---- | --------------- | --------------------------------- | +| [0] | address payable | The name's corresponding address. | + +### addressManager + +```solidity +function addressManager() public view returns (address) +``` + +Returns the AddressManager's address. + +#### Return Values + +| Name | Type | Description | +| ---- | ------- | ----------------------------- | +| [0] | address | The AddressManager's address. | + +### \_init + +```solidity +function _init(address addressManager_) internal virtual +``` + +### \_resolve + +```solidity +function _resolve(uint256 chainId, string name) private view returns (address payable) +``` diff --git a/packages/website/docs/reference/smart-contracts/common/ConfigManager.md b/packages/website/docs/reference/smart-contracts/common/ConfigManager.md new file mode 100644 index 0000000000..da0a49d19d --- /dev/null +++ b/packages/website/docs/reference/smart-contracts/common/ConfigManager.md @@ -0,0 +1,31 @@ +## ConfigManager + +### kv + +```solidity +mapping(bytes32 => bytes) kv +``` + +### Updated + +```solidity +event Updated(string name, bytes newVal, bytes oldVal) +``` + +### init + +```solidity +function init() external +``` + +### setValue + +```solidity +function setValue(string name, bytes val) external +``` + +### getValue + +```solidity +function getValue(string name) public view returns (bytes) +``` diff --git a/packages/website/docs/reference/smart-contracts/common/IAddressManager.md b/packages/website/docs/reference/smart-contracts/common/IAddressManager.md new file mode 100644 index 0000000000..7b3385956e --- /dev/null +++ b/packages/website/docs/reference/smart-contracts/common/IAddressManager.md @@ -0,0 +1,41 @@ +## IAddressManager + +Interface to set and get an address for a name. + +### setAddress + +```solidity +function setAddress(string name, address addr) external +``` + +Associate an address to a name. + +_The original address associated with the name, if exists, will be +replaced._ + +#### Parameters + +| Name | Type | Description | +| ---- | ------- | -------------------------------------------------- | +| name | string | The name which an address will be associated with. | +| addr | address | The address to be associated with the given name. | + +### getAddress + +```solidity +function getAddress(string name) external view returns (address) +``` + +Returns the address associated with the given name. + +#### Parameters + +| Name | Type | Description | +| ---- | ------ | ----------------------------------------------- | +| name | string | The name for which an address will be returned. | + +#### Return Values + +| Name | Type | Description | +| ---- | ------- | -------------------------------------------------------------------------------------------------- | +| [0] | address | The address associated with the given name. If no address is found, `address(0)` will be returned. | diff --git a/packages/website/docs/reference/smart-contracts/common/IHeaderSync.md b/packages/website/docs/reference/smart-contracts/common/IHeaderSync.md new file mode 100644 index 0000000000..d0086de8e1 --- /dev/null +++ b/packages/website/docs/reference/smart-contracts/common/IHeaderSync.md @@ -0,0 +1,21 @@ +## IHeaderSync + +Interface to set and get an address for a name. + +### HeaderSynced + +```solidity +event HeaderSynced(uint256 height, uint256 srcHeight, bytes32 srcHash) +``` + +### getSyncedHeader + +```solidity +function getSyncedHeader(uint256 number) external view returns (bytes32) +``` + +### getLatestSyncedHeader + +```solidity +function getLatestSyncedHeader() external view returns (bytes32) +``` diff --git a/packages/website/docs/reference/smart-contracts/common/IMintableERC20.md b/packages/website/docs/reference/smart-contracts/common/IMintableERC20.md new file mode 100644 index 0000000000..e3cc948939 --- /dev/null +++ b/packages/website/docs/reference/smart-contracts/common/IMintableERC20.md @@ -0,0 +1,13 @@ +## IMintableERC20 + +### mint + +```solidity +function mint(address account, uint256 amount) external +``` + +### burn + +```solidity +function burn(address account, uint256 amount) external +``` diff --git a/packages/website/docs/reference/whitepaper.md b/packages/website/docs/reference/whitepaper.md new file mode 100644 index 0000000000..2150c7b0a4 --- /dev/null +++ b/packages/website/docs/reference/whitepaper.md @@ -0,0 +1,3 @@ +# Whitepaper + +Read about the Taiko protocol in depth with the [whitepaper](https://taikoxyz.github.io/taiko-mono/taiko-whitepaper.pdf). diff --git a/packages/website/docusaurus.config.js b/packages/website/docusaurus.config.js index 2fd10b2ffd..47f8b4e54c 100644 --- a/packages/website/docusaurus.config.js +++ b/packages/website/docusaurus.config.js @@ -1,8 +1,8 @@ // @ts-check // Note: type annotations allow type checking and IDEs autocompletion -const lightCodeTheme = require("prism-react-renderer/themes/github"); -const darkCodeTheme = require("prism-react-renderer/themes/dracula"); +const lightCodeTheme = require("prism-react-renderer/themes/duotoneLight"); +const darkCodeTheme = require("prism-react-renderer/themes/duotoneDark"); const math = require("remark-math"); const katex = require("rehype-katex"); diff --git a/packages/website/src/components/Hero/index.tsx b/packages/website/src/components/Hero/index.tsx index 2ab6eacb56..71978fb327 100644 --- a/packages/website/src/components/Hero/index.tsx +++ b/packages/website/src/components/Hero/index.tsx @@ -6,16 +6,8 @@ export default function Hero() {
-

- - A - - Type 1{" "} - - - ZK-EVM - - {" "} +

+ A Type 1 ZK-EVM

Fully decentralized, Ethereum-equivalent ZK-Rollup.