diff --git a/apps/blockchain/README.md b/apps/blockchain/README.md index 0f288793..b3dfc213 100644 --- a/apps/blockchain/README.md +++ b/apps/blockchain/README.md @@ -1,10 +1,10 @@ -# Starklane technical guide +# ArkProject Bridge technical guide -Starklane is a suite of tools for developers to easily bridge asset between Ethereum and Starknet. +ArkProject Bridge is a suite of tools for developers to easily bridge asset between Ethereum and Starknet. It should not be seen as a very generic tool as Starkgate provides. As the considerations and implications of bridging a NFT are very different. -The current implementation of Starklane is aiming at supporting both [ERC721](https://eips.ethereum.org/EIPS/eip-721) and [ERC1155](https://eips.ethereum.org/EIPS/eip-1155). In the case of ERC1155, there are economics implications of bridging assets that are beyond the scope of this document. The ERC721 is easier to handle due to the inherent uniqueness of a token. +The current implementation of ArkProject Bridge is aiming at supporting both [ERC721](https://eips.ethereum.org/EIPS/eip-721) and [ERC1155](https://eips.ethereum.org/EIPS/eip-1155). In the case of ERC1155, there are economics implications of bridging assets that are beyond the scope of this document. The ERC721 is easier to handle due to the inherent uniqueness of a token. # Considerations @@ -12,24 +12,24 @@ Working with ERC721 and ERC1155 contracts has different constraints on Ethereum - **ERC721**: The metadata (Token URI most importantly) for a token can be implemented in diverse manners. Using a base URI concatenating the token id, or having a string stored for each token. Even if the base URI is often use, we still see some URIs being stored. We can see here the first choice to make when a token is bridged. Is the URI required to be explicit bridged for each token, or only bridging the base URI is sufficient. -This is then tied to what is the design choice made by the developer / collection owner. Starklane supports both. +This is then tied to what is the design choice made by the developer / collection owner. ArkProject Bridge supports both. - **ERC1155**: Metadata for ERC1155 is from the beginning using a base URI. Which is implemented in this same fashion for every contracts. However, with ERC1155, the consideration is about economics and how to keep track of tokens amounts being bridge. In fact, as token may not be unique - and even unique token are not guaranteed to be unique, the escrow mechanism to hold the tokens when bridged can’t follow the same logic as ERC721 escrow does. This topic is still under discussion at Screenshot Labs, but the most viable option seems to be a burn of the tokens being bridged, and mint them again if they are bridged from the other chain. But again, this is more about economics than technical consideration. -- **Cairo version**: Starklane is being updated to be compliant with `v2.4.0`. +- **Cairo version**: ArkProject Bridge is being updated to be compliant with `v2.6.4`. - **Starknet messaging asymmetry**: The native messaging proposed by Starknet is working differently based on which direction assets are bridged. L1→L2: From a single transaction on Ethereum, the message is registered and emitted as an event by the Starknet Core Contract, and the sequencer is responsible of gathering those events to then send (automatically) a `L1Handler` transaction to the destination contract on Starknet. L2→L1: When a transaction is made on Starknet with a message for Ethereum, the message is included in a block (Ethereum is not listening to events). Once this block is proven, Starknet Core Contract is capable of taking this message in account, and at this moment a transaction on Ethereum must be realized to actually consume the message (and thus execute the logic associated to it). At the moment of this writing, the proving time is quite long for a good UX. For this reason, we propose to developer to use an indexer that is able to fire transactions on Ethereum reacting on the `requests` being included in a block (and emitted in an event). This transaction has more cost, and the developer / collection owner can choose to pay the costs upfront for his users, charge more fees at the moment of the deposit, or simply let the user do the withdraw when the block is proven without firing this transaction. Important to note that this transaction to “consume the message before the block is being proved” is implemented in a way that even when the block is proven later, the “consume message” proposed by Starknet Core will be invalid. This ensure the tokens can’t be withdrawn two times. -- **Auto-deploy of contracts**: As some collection owner that are bridging may not have deployed a collection on the other chain to receive the token, Starklane is auto-deploying a contract to receive the tokens if no collection address on the destination chain is given in the request. This contract is proxied on Ethereum, and upgradable on Starknet, to ensure that the owner can take back the full control without loosing the data. -Those auto-deployed contract implements the `IStarklaneBridgeable` interface, which ensures that the contract can receive/send token through Starklane. +- **Auto-deploy of contracts**: As some collection owner that are bridging may not have deployed a collection on the other chain to receive the token, ArkProject Bridge is auto-deploying a contract to receive the tokens if no collection address on the destination chain is given in the request. This contract is proxied on Ethereum, and upgradable on Starknet, to ensure that the owner can take back the full control without loosing the data. +Those auto-deployed contract implements the `IStarklaneBridgeable` interface, which ensures that the contract can receive/send token through ArkProject Bridge. If the collection owner / developer already deployed a contract, this contract must implement `IStarklaneBridgeable` to interact with the bridge. # Request protocol -Starklane has a protocol designed to work around a `request` to bridge assets. A `request` is self explanatory about the collection and tokens to bridge. +ArkProject Bridge has a protocol designed to work around a `request` to bridge assets. A `request` is self explanatory about the collection and tokens to bridge. A single `request` can bridge one or more tokens for **ONE** collection. To bridge assets of different collections, several `request` must be made. @@ -85,9 +85,9 @@ struct Request { - Withdraw strategies: When assets are bridge from Ethereum to Starknet, the withdraw is always `auto` as the transaction `L1Handler` is fired by the sequencer. When transferring assets from Starknet to Ethereum, the withdraw strategies are: `auto` ⇒ The indexer fires a transaction on Ethereum when the `request` is included in a block produced on starknet (but not yet proven) which triggers the automatic withdraw of the assets on L1. -`manual` ⇒ The withdraw of the assets will be possible only when the block in which the `request` was included is being proven. At this moment, the user must send a transaction to Starklane contract on Ethereum to withdraw the assets. +`manual` ⇒ The withdraw of the assets will be possible only when the block in which the `request` was included is being proven. At this moment, the user must send a transaction to ArkProject Bridge contract on Ethereum to withdraw the assets. - Deposit strategies: -`escrow` ⇒ The token is held on escrow by Starklane contract. A token held on escrow by Starklane contract may also be burnt by the collection owner (i.e.: When the token is safely bridge, and the collection owner wants to burn the collection after being bridged). +`escrow` ⇒ The token is held on escrow by ArkProject Bridge contract. A token held on escrow by ArkProject Bridge contract may also be burnt by the collection owner (i.e.: When the token is safely bridge, and the collection owner wants to burn the collection after being bridged). `burn-auto` ⇒ This one uses the same approach as the `withdraw-auto`, when the request is successfully processed (assets are bridged), the indexer fires a transaction on the other chain to burn the tokens. This works for both Ethereum and Starknet, as the messaging is asynchronous. This is the safest way to automatically handle the burn, even if the cost is a bit higher. TODO: May we consider separating a `burn` and `burn-auto`? To allow the same transaction to burn then bridge? But it’s very risky, for ERC721 especially as a burnt token can’t be minted again. @@ -100,11 +100,3 @@ The hash computation includes only one collection address, the collection addres You can find a first representation of the FMS on this [figma](https://www.figma.com/file/esIDAZS1UySOAtq7hMa5xQ/FSM-For-Starklane---L1---L2?type=whiteboard&node-id=0-1&t=LqPt9ELDlcVdz29t-0). We're currently reviewing and we will detail more some steps to ensure a better preparation for the audit and easier for someone to dive into the project. -# TODOs -- [ ] Review linear / github issue. -- [ ] Add forge binary with l2_handler_caller for CI (waiting the PR to be merged). -- [ ] Rework ethereum to optimize size of contrat. -- [ ] Terminate indexer to allow withdraw auto on ethereum + burn auto both side. -- [ ] Check metadata for ERC1155 and ERC721 (how to allow all strategies to be included). -- [ ] Connect UI both sides with new contract interface. -- [ ] Validate new implementation in Katana to submit PR. diff --git a/apps/blockchain/ethereum/.env.anvil b/apps/blockchain/ethereum/.env.anvil index fa32bf64..a5a3bc28 100644 --- a/apps/blockchain/ethereum/.env.anvil +++ b/apps/blockchain/ethereum/.env.anvil @@ -1,12 +1,15 @@ # General config. ETH_RPC_URL=http://127.0.0.1:8545 -ETHERSCAN_API_KEY=YGJJHTCQBYE2C336HMUCY5P27MJY885IIN LOCAL_LOGS=logs/ +ETHERSCAN_API_KEY=fake_key # Account related variables (EOA account). ACCOUNT_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 ACCOUNT_ADDRESS=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 +ETHEREUM_USER_ADDR=0x70997970C51812dc3A010C7d01b50e0d17dc79C8 +ETHEREUM_USER_PRIVATE_KEY=0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d + # Starklane L1 variables. STARKNET_CORE_L1_ADDRESS=0x0000000000000000000000000000000000000000 STARKLANE_L1_PROXY_ADDRESS=0x0000000000000000000000000000000000000000 @@ -16,3 +19,6 @@ STARKLANE_L1_PROXY_ADDRESS=0x0000000000000000000000000000000000000000 STARKLANE_L2_ADDRESS=0x075af152a7ad8c32726093fdf9820de103854d15a8ef4fae11d2739671ff1f9e STARKLANE_L2_SELECTOR=0x005d25c8970b257e237fddc686e4a2711310774d2277107e1ebaf3e0a68dd037 OWNER_L2_ADDRESS=0x1 + +alias cast_admin_send="cast send --private-key ${ACCOUNT_PRIVATE_KEY}" +alias cast_user_send="cast send --private-key ${ETHEREUM_USER_PRIVATE_KEY}" diff --git a/apps/blockchain/ethereum/foundry.toml b/apps/blockchain/ethereum/foundry.toml index 95b138d6..74cc0826 100644 --- a/apps/blockchain/ethereum/foundry.toml +++ b/apps/blockchain/ethereum/foundry.toml @@ -14,4 +14,4 @@ anvil = "http://127.0.0.1:8545" [etherscan] goerli = { key = "${ETHERSCAN_API_KEY}" } -anvil = { key = "${ETHERSCAN_API_KEY", chainId=31337} +anvil = { key = "FAKE KEY", chainId=31337} diff --git a/apps/blockchain/local_setup.md b/apps/blockchain/local_setup.md new file mode 100644 index 00000000..ecef8727 --- /dev/null +++ b/apps/blockchain/local_setup.md @@ -0,0 +1,294 @@ +# ArkProject Bridge Local setup + +## Dependencies version +- jq: 1.7.1 +- foundry: forge 0.2.0 (ea7817c) +- asdf: v0.14.0 +- scarb: 2.6.4 +- dojo: 0.7.0 +- starkli: 0.2.9 +- starknet-foundry: 0.19.0 + +## Bridge setup +### L1 setup +##### Enter `ethereum` directory +```shell +blockchain$ cd ethereum +``` + +##### Copy environment file +```shell +ethereum$ cp .env.anvil .env +``` + +##### Start Anvil in another shell +```shell +ethereum$ anvil +``` + +##### Deploy messaging contract +```shell +ethereum$ forge script --broadcast --rpc-url anvil script/LocalMessaging.s.sol:LocalMessaging +``` +Local messaging contract address is available in `logs/local_messaging_deploy.json`: +``` +{ + "data": { + "sncore_address": "0x5FbDB2315678afecb367f032d93F642f64180aa3", + "success": true + } +} +``` + +##### Deploy ERC721Bridgeable contract +```shell +ethereum$ ERC721_PROXY_ADDRESS=0x0000000000000000000000000000000000000000 forge script --broadcast --rpc-url anvil script/ERC721.s.sol:Deploy +``` +ERC721 contract address is available in `logs/erc721_deploy.json`: +``` +{ + "data": { + "impl_address": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512", + "proxy_address": "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0", + "success": true + } +} +``` + +##### Deploy Bridge and local messaging contract +```shell +ethereum$ STARKNET_CORE_L1_ADDRESS=$(cat logs/local_messaging_deploy.json | jq '.data.sncore_address' | sed 's|"||g') forge script --broadcast --rpc-url anvil script/Starklane.s.sol:Deploy + +``` +Bridge contract address is available in `logs/starklane_deploy.json`: +``` +{ + "data": { + "impl_address": "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9", + "proxy_address": "0x5FC8d32690cc91D4c39d9d3abcBD16989F875707", + "sncore_address": "0x5FbDB2315678afecb367f032d93F642f64180aa3", + "success": true + } +} +``` +**Bridge L1 address: `0x5FC8d32690cc91D4c39d9d3abcBD16989F875707`** +```shell +ethereum$ export BRIDGE_L1_ADDR=0x5FC8d32690cc91D4c39d9d3abcBD16989F875707 +``` + +------ +### L2 setup +##### Enter `starknet` directory +```shell +blockchain$ cd starknet +``` + +##### Start katana in another shell +```shell +starknet$ katana --messaging ./data/anvil.messaging.json --seed 0 +``` + +##### Build contracts +```shell +starknet$ scarb build +``` + +##### Setup environment +```shell +starknet$ cp .env.katana .env +starknet$ source .env +``` + +##### Declare ERC721 bridgeable class +```shell +starknet$ starkli_deployer declare --compiler-version 2.6.2 --watch ./target/dev/starklane_erc721_bridgeable.contract_class.json +``` +```console +WARNING: using private key in plain text is highly insecure, and you should ONLY do this for development. Consider using an encrypted keystore instead. (Check out https://book.starkli.rs/signers on how to suppress this warning) +Declaring Cairo 1 class: 0x0122d394f5b7a23efd3c9a80740ce6e0c9764ab66c75f2bb5df2968e02a7206e +Compiling Sierra class to CASM with compiler version 2.6.2... +CASM class hash: 0x0192a1b69fa90d13eb8514b05b85b47f035db2a8b9e8cf949ffc91a31fb1cc13 +Contract declaration transaction: 0x05f58015bfbcf65ec8c74329266a89c32d760ccde538b5b9591d98187a18fbf8 +Waiting for transaction 0x05f58015bfbcf65ec8c74329266a89c32d760ccde538b5b9591d98187a18fbf8 to confirm... +Transaction not confirmed yet... +Transaction 0x05f58015bfbcf65ec8c74329266a89c32d760ccde538b5b9591d98187a18fbf8 confirmed +Class hash declared: +0x0122d394f5b7a23efd3c9a80740ce6e0c9764ab66c75f2bb5df2968e02a7206e +``` +**ERC721 Bridgeable class hash is: `0x0122d394f5b7a23efd3c9a80740ce6e0c9764ab66c75f2bb5df2968e02a7206e`** +```shell +starknet$ export ERC721_BRIDGEABLE_CLASSHASH=0x0122d394f5b7a23efd3c9a80740ce6e0c9764ab66c75f2bb5df2968e02a7206e +``` + +##### Declare Bridge class +```shell +starknet$ starkli_deployer declare --compiler-version 2.6.2 --watch ./target/dev/starklane_bridge.contract_class.json +``` +```console +WARNING: using private key in plain text is highly insecure, and you should ONLY do this for development. Consider using an encrypted keystore instead. (Check out https://book.starkli.rs/signers on how to suppress this warning) +Declaring Cairo 1 class: 0x04121c3429b2f6496b2334b780657b6368267fd2c3d37be414065a37ef1311db +Compiling Sierra class to CASM with compiler version 2.6.2... +CASM class hash: 0x002fd7b0c45bbc0df368bc724ececcdd1e9b8028f5f6ca154adffad264e73f73 +Contract declaration transaction: 0x01037d5d1f91e1bc2e35936ea1fa026e114d06a44601144ceb284d2587b02eeb +Waiting for transaction 0x01037d5d1f91e1bc2e35936ea1fa026e114d06a44601144ceb284d2587b02eeb to confirm... +Transaction not confirmed yet... +Transaction 0x01037d5d1f91e1bc2e35936ea1fa026e114d06a44601144ceb284d2587b02eeb confirmed +Class hash declared: +0x04121c3429b2f6496b2334b780657b6368267fd2c3d37be414065a37ef1311db +``` +**Bridge classhash is `0x04121c3429b2f6496b2334b780657b6368267fd2c3d37be414065a37ef1311db`** +```shell +starknet$ export BRIDGE_CLASSHASH=0x04121c3429b2f6496b2334b780657b6368267fd2c3d37be414065a37ef1311db +``` + +##### Deploy bridge +```shell +starknet$ starkli_deployer deploy --salt 0x1234 --watch ${BRIDGE_CLASSHASH} ${STARKNET_ADMIN_ADDR} ${BRIDGE_L1_ADDR} ${ERC721_BRIDGEABLE_CLASSHASH} +``` +```console +WARNING: using private key in plain text is highly insecure, and you should ONLY do this for development. Consider using an encrypted keystore instead. (Check out https://book.starkli.rs/signers on how to suppress this warning) +Deploying class 0x04121c3429b2f6496b2334b780657b6368267fd2c3d37be414065a37ef1311db with salt 0x0000000000000000000000000000000000000000000000000000000000001234... +The contract will be deployed at address 0x0155713d9f99c3cba8eea4dcf3224a60162de750a426d6d17ba81b338d82ce6d +Contract deployment transaction: 0x022bfc3e16913155edfed1bdb2318c4a2a8e002303c7dbe1062017685e57c48e +Waiting for transaction 0x022bfc3e16913155edfed1bdb2318c4a2a8e002303c7dbe1062017685e57c48e to confirm... +Transaction not confirmed yet... +Transaction 0x022bfc3e16913155edfed1bdb2318c4a2a8e002303c7dbe1062017685e57c48e confirmed +Contract deployed: +0x0155713d9f99c3cba8eea4dcf3224a60162de750a426d6d17ba81b338d82ce6d +``` +**Bridge address is `0x0155713d9f99c3cba8eea4dcf3224a60162de750a426d6d17ba81b338d82ce6d`** +```shell +starknet$ export BRIDGE_L2_ADDR=0x0155713d9f99c3cba8eea4dcf3224a60162de750a426d6d17ba81b338d82ce6d +``` +------ +### Testing transfert + +A mintable collection is already deployed at **`${ERC721_L1_ADDR}`** and token ID 3 & 4 are owned by **`${ETHEREUM_USER}`** + +##### Enable L1 Bridge white list +```shell +ethereum$ cast_admin_send ${BRIDGE_L1_ADDR} "enableWhiteList(bool)" true +``` + +##### Set L1 collection mapping +```shell +ethereum$ cast_admin_send ${BRIDGE_L1_ADDR} "setL1L2CollectionMapping(address,uint256,bool)" ${ERC721_L1_ADDR} ${ERC721_L2_ADDR} false +``` + +##### Whitelist L1 collection +```shell +ethereum$ cast_admin_send ${BRIDGE_L1_ADDR} "whiteList(address,bool)" ${ERC721_L1_ADDR} true +``` + +##### Enable L1 Bridge +```shell +ethereum$ cast_admin_send ${BRIDGE_L1_ADDR} "enableBridge(bool)" true +``` + +##### Deploy ERC721 bridgeable as a test ERC721 collection +``` +ByteArray +collection_test -> 0x0 0x636f6c6c656374696f6e5f74657374 0xf +CTEST -> 0x0 0x4354455354 0x5 +URI -> 0x0 0x555249 0x3 +``` +```shell +starknet$ starkli_deployer deploy --salt 0x8822 --watch ${ERC721_BRIDGEABLE_CLASSHASH} 0x0 0x636f6c6c656374696f6e5f74657374 0xf 0x0 0x4354455354 0x5 0x0 0x555249 0x3 ${BRIDGE_L1_ADDR} ${STARKNET_OWNER_ADDR} +``` +```console +WARNING: using private key in plain text is highly insecure, and you should ONLY do this for development. Consider using an encrypted keystore instead. (Check out https://book.starkli.rs/signers on how to suppress this warning) +Deploying class 0x0122d394f5b7a23efd3c9a80740ce6e0c9764ab66c75f2bb5df2968e02a7206e with salt 0x0000000000000000000000000000000000000000000000000000000000008822... +The contract will be deployed at address 0x024c05a4d71b45b536a3e94e1f06b7ca7c948ac4db328d672760ed2dd1ecea29 +Contract deployment transaction: 0x07f0ed60dc8033e54ae54fbfc36868d00bc246512e1cc96dfa76b94251084995 +Contract deployed: +0x024c05a4d71b45b536a3e94e1f06b7ca7c948ac4db328d672760ed2dd1ecea29 +``` +**Collection address is `0x024c05a4d71b45b536a3e94e1f06b7ca7c948ac4db328d672760ed2dd1ecea29`** +```shell +starknet$ export ERC721_L2_ADDR=0x024c05a4d71b45b536a3e94e1f06b7ca7c948ac4db328d672760ed2dd1ecea29 +``` + +##### Mint NFT for user +```shell +starknet$ starkli_owner invoke --watch ${ERC721_L2_ADDR} mint_range ${STARKNET_USER_ACCOUNT_ADDR} u256:0 u256:10 +``` + +##### Enable Bridge white list +```shell +starknet$ starkli_admin invoke --watch ${BRIDGE_L2_ADDR} enable_white_list 1 +``` + +##### Set collection mapping +```shell +starknet$ starkli_admin invoke --watch ${BRIDGE_L2_ADDR} set_l1_l2_collection_mapping ${ERC721_L1_ADDR} ${ERC721_L2_ADDR} +``` + +##### Whitelist collection +```shell +starknet$ starkli_admin invoke --watch ${BRIDGE_L2_ADDR} white_list_collection ${ERC721_L2_ADDR} 1 +``` + +##### Enable Bridge +```shell +starknet$ starkli_admin invoke --watch ${BRIDGE_L2_ADDR} enable 1 +``` + +----- +#### L1->L2 transfert + +##### Approve ERC721 for transfert +```shell +ethereum$ cast_user_send ${ERC721_L1_ADDR} "approve(address,uint256)" ${BRIDGE_L1_ADDR} 3 +``` +```shell +ethereum$ cast_user_send ${ERC721_L1_ADDR} "approve(address,uint256)" ${BRIDGE_L1_ADDR} 4 +``` + +##### Bridge NFT 3 & 4 +```shell +ethereum$ cast_user_send ${BRIDGE_L1_ADDR} "depositTokens(uint256,address,uint256,uint256[],bool)" 0x123 ${ERC721_L1_ADDR} ${STARKNET_USER_ACCOUNT_ADDR} "[3,4]" false +``` + +------ +#### L2->L1 transfert + +##### Approve ERC721 for transfert +```shell +starknet$ starkli_user invoke --watch ${ERC721_L2_ADDR} approve ${BRIDGE_L2_ADDR} u256:1 +``` +```console +WARNING: using private key in plain text is highly insecure, and you should ONLY do this for development. Consider using an encrypted keystore instead. (Check out https://book.starkli.rs/signers on how to suppress this warning) +Invoke transaction: 0x0756a1b0ddb2b12d966a2698838416b119015ca1d36e6986d5b1e7f811e82d6a +Waiting for transaction 0x0756a1b0ddb2b12d966a2698838416b119015ca1d36e6986d5b1e7f811e82d6a to confirm... +Transaction not confirmed yet... +Transaction 0x0756a1b0ddb2b12d966a2698838416b119015ca1d36e6986d5b1e7f811e82d6a confirmed +``` +```shell +starknet$ starkli_user invoke --watch ${ERC721_L2_ADDR} approve ${BRIDGE_L2_ADDR} u256:2 +``` +```console +WARNING: using private key in plain text is highly insecure, and you should ONLY do this for development. Consider using an encrypted keystore instead. (Check out https://book.starkli.rs/signers on how to suppress this warning) +Invoke transaction: 0x01a9e875ee67b7c8aebd2d50d0908716fd6d60ffa290fe82803483bb21e618df +Waiting for transaction 0x01a9e875ee67b7c8aebd2d50d0908716fd6d60ffa290fe82803483bb21e618df to confirm... +Transaction not confirmed yet... +Transaction 0x01a9e875ee67b7c8aebd2d50d0908716fd6d60ffa290fe82803483bb21e618df confirmed +``` + +##### Bridge NFT 1 & 2 +```shell +starknet$ starkli_user invoke --watch ${BRIDGE_L2_ADDR} deposit_tokens $(date +%s%N) ${ERC721_L2_ADDR} ${ETH_ACCOUNT} 2 u256:1 u256:2 0 0 +``` +```console +WARNING: using private key in plain text is highly insecure, and you should ONLY do this for development. Consider using an encrypted keystore instead. (Check out https://book.starkli.rs/signers on how to suppress this warning) +Invoke transaction: 0x04a40e9a337fe35ccdddb9a2f646c2f5e205673ca656ab77d4049f127deacde2 +Waiting for transaction 0x04a40e9a337fe35ccdddb9a2f646c2f5e205673ca656ab77d4049f127deacde2 to confirm... +Transaction not confirmed yet... +Transaction 0x04a40e9a337fe35ccdddb9a2f646c2f5e205673ca656ab77d4049f127deacde2 confirmed +``` +**Transaction hash: `0x04a40e9a337fe35ccdddb9a2f646c2f5e205673ca656ab77d4049f127deacde2`** + +Payload required to withdraw ERC721 on L1, can be extracted with: +```shell +starknet$ starkli_user tx-receipt 0x04a40e9a337fe35ccdddb9a2f646c2f5e205673ca656ab77d4049f127deacde2 | jq '.messages_sent[0].payload' +``` + diff --git a/apps/blockchain/starknet/.env.katana b/apps/blockchain/starknet/.env.katana index dfc9966d..08b3d926 100644 --- a/apps/blockchain/starknet/.env.katana +++ b/apps/blockchain/starknet/.env.katana @@ -1,13 +1,30 @@ -STARKNET_ACCOUNT=./data/katana_account.json STARKNET_RPC=http://0.0.0.0:5050 -#STARKNET_KEYSTORE=./data/katana_key.json -PRIVATE_KEY=0x1800000000300000180000000000030000000000003006001800006600 -ADMIN_ACCOUNT_ADDR=0x517ececd29116499f4a1b64b094da79ba08dfd54a3edaa316134c41f8160973 -ETH_ACCOUNT=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 -BRIDGE_L1_ADDRESS=0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0 +# Deployer +STARKNET_DEPLOYER_ACCOUNT=./data/katana_deployer_account.json +STARKNET_DEPLOYER_PRIVATE_KEY=0x6bf3604bcb41fed6c42bcca5436eeb65083a982ff65db0dc123f65358008b51 +STARKNET_DEPLOYER_ADDR=0x56c155b624fdf6bfc94f7b37cf1dbebb5e186ef2e4ab2762367cd07c8f892a1 + +# Bridge admin +STARKNET_ADMIN_ACCOUNT=./data/katana_admin_account.json +STARKNET_ADMIN_PRIVATE_KEY=0x283d1e73776cd4ac1ac5f0b879f561bded25eceb2cc589c674af0cec41df441 +STARKNET_ADMIN_ADDR=0x66efb28ac62686966ae85095ff3a772e014e7fbf56d4c5f6fac5606d4dde23a + +# Owner of ERC721 collection +STARKNET_OWNER_ACCOUNT=./data/katana_owner_account.json +STARKNET_OWNER_PRIVATE_KEY=0x1c9053c053edf324aec366a34c6901b1095b07af69495bffec7d7fe21effb1b +STARKNET_OWNER_ADDR=0x6b86e40118f29ebe393a75469b4d926c7a44c2e2681b6d319520b7c1156d114 -# | Account address | 0x64b48806902a367c8598f4f95c305e8c1a1acba5f082d294a43793113115691 -# | Private key | 0x71d7bb07b9a64f6f78ac4c816aff4da9 -# | Public key | 0x39d9e6ce352ad4530a0ef5d5a18fd3303c3606a7fa6ac5b620020ad681cc33b +# User +STARKNET_USER_ACCOUNT=./data/katana_account.json +STARKNET_USER_PRIVATE_KEY=0x1800000000300000180000000000030000000000003006001800006600 +STARKNET_USER_ACCOUNT_ADDR=0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03 + +ETH_ACCOUNT=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 +BRIDGE_L1_ADDR=0x5FC8d32690cc91D4c39d9d3abcBD16989F875707 +# starkli alias +alias starkli_deployer="STARKNET_RPC=${STARKNET_RPC} STARKNET_ACCOUNT=${STARKNET_DEPLOYER_ACCOUNT} STARKNET_PRIVATE_KEY=${STARKNET_DEPLOYER_PRIVATE_KEY} starkli" +alias starkli_admin="STARKNET_RPC=${STARKNET_RPC} STARKNET_ACCOUNT=${STARKNET_ADMIN_ACCOUNT} STARKNET_PRIVATE_KEY=${STARKNET_ADMIN_PRIVATE_KEY} starkli" +alias starkli_owner="STARKNET_RPC=${STARKNET_RPC} STARKNET_ACCOUNT=${STARKNET_OWNER_ACCOUNT} STARKNET_PRIVATE_KEY=${STARKNET_OWNER_PRIVATE_KEY} starkli" +alias starkli_user="STARKNET_RPC=${STARKNET_RPC} STARKNET_ACCOUNT=${STARKNET_USER_ACCOUNT} STARKNET_PRIVATE_KEY=${STARKNET_USER_PRIVATE_KEY} starkli" diff --git a/apps/blockchain/starknet/.tool-versions b/apps/blockchain/starknet/.tool-versions index b5a32a0e..25cf58de 100644 --- a/apps/blockchain/starknet/.tool-versions +++ b/apps/blockchain/starknet/.tool-versions @@ -1,2 +1,4 @@ scarb 2.6.4 starknet-foundry 0.19.0 +dojo 0.7.0 +starkli 0.2.9 diff --git a/apps/blockchain/starknet/data/anvil.messaging.json b/apps/blockchain/starknet/data/anvil.messaging.json new file mode 100644 index 00000000..941d5fe5 --- /dev/null +++ b/apps/blockchain/starknet/data/anvil.messaging.json @@ -0,0 +1,9 @@ +{ + "chain": "ethereum", + "rpc_url": "http://127.0.0.1:8545", + "contract_address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", + "sender_address": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + "private_key": "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", + "interval": 2, + "from_block": 0 +} diff --git a/apps/blockchain/starknet/data/katana_account.json b/apps/blockchain/starknet/data/katana_account.json index 788b3102..db9480cf 100644 --- a/apps/blockchain/starknet/data/katana_account.json +++ b/apps/blockchain/starknet/data/katana_account.json @@ -3,11 +3,12 @@ "variant": { "type": "open_zeppelin", "version": 1, - "public_key": "0x2b191c2f3ecf685a91af7cf72a43e7b90e2e41220175de5c4f7498981b10053" + "public_key": "0x2b191c2f3ecf685a91af7cf72a43e7b90e2e41220175de5c4f7498981b10053", + "legacy": false }, "deployment": { "status": "deployed", - "class_hash": "0x4d07e40e93398ed3c76981e72dd1fd22557a78ce36c0515f679e27f0bb5bc5f", + "class_hash": "0x05400e90f7e0ae78bd02c77cd75527280470e2fe19c54970dd79dc37a9d3645c", "address": "0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03" } } diff --git a/apps/blockchain/starknet/data/katana_admin_account.json b/apps/blockchain/starknet/data/katana_admin_account.json new file mode 100644 index 00000000..c63c8d9d --- /dev/null +++ b/apps/blockchain/starknet/data/katana_admin_account.json @@ -0,0 +1,15 @@ +{ + "version": 1, + "variant": { + "type": "open_zeppelin", + "version": 1, + "public_key": "0x73c8a29ba0e6a368422d0551b3f45a30a27166b809ba07a41a1bc434b000ba7", + "legacy": false + }, + "deployment": { + "status": "deployed", + "class_hash": "0x05400e90f7e0ae78bd02c77cd75527280470e2fe19c54970dd79dc37a9d3645c", + "address": "0x66efb28ac62686966ae85095ff3a772e014e7fbf56d4c5f6fac5606d4dde23a" + } + } + \ No newline at end of file diff --git a/apps/blockchain/starknet/data/katana_deployer_account.json b/apps/blockchain/starknet/data/katana_deployer_account.json new file mode 100644 index 00000000..ea839d12 --- /dev/null +++ b/apps/blockchain/starknet/data/katana_deployer_account.json @@ -0,0 +1,14 @@ +{ + "version": 1, + "variant": { + "type": "open_zeppelin", + "version": 1, + "public_key": "0x4b076e402835913e3f6812ed28cef8b757d4643ebf2714471a387cb10f22be3", + "legacy": false + }, + "deployment": { + "status": "deployed", + "class_hash": "0x5400e90f7e0ae78bd02c77cd75527280470e2fe19c54970dd79dc37a9d3645c", + "address": "0x56c155b624fdf6bfc94f7b37cf1dbebb5e186ef2e4ab2762367cd07c8f892a1" + } +} diff --git a/apps/blockchain/starknet/data/katana_owner_account.json b/apps/blockchain/starknet/data/katana_owner_account.json new file mode 100644 index 00000000..49d6ac25 --- /dev/null +++ b/apps/blockchain/starknet/data/katana_owner_account.json @@ -0,0 +1,14 @@ +{ + "version": 1, + "variant": { + "type": "open_zeppelin", + "version": 1, + "public_key": "0x4c339f18b9d1b95b64a6d378abd1480b2e0d5d5bd33cd0828cbce4d65c27284", + "legacy": false + }, + "deployment": { + "status": "deployed", + "class_hash": "0x5400e90f7e0ae78bd02c77cd75527280470e2fe19c54970dd79dc37a9d3645c", + "address": "0x6b86e40118f29ebe393a75469b4d926c7a44c2e2681b6d319520b7c1156d114" + } +}