Louis Guthmann
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
      • No invitee
    • Publish Note

      Publish Note

      Everyone on the web can find and read all notes of this public team.
      Once published, notes can be searched and viewed by anyone online.
      See published notes
      Please check the box to agree to the Community Guidelines.
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
No invitee
Publish Note

Publish Note

Everyone on the web can find and read all notes of this public team.
Once published, notes can be searched and viewed by anyone online.
See published notes
Please check the box to agree to the Community Guidelines.
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# StarkWare JSON-RPC Spec JSON-RPC specification for wallet interaction for starkware methods All examples use the parameters described in [testing environment](#Testing-Environment) section. Finally all parameter types can be found in more detail [here](#Parameter-Types). ## Methods ### Connection (No Signature Involved) ### Get Account The method `stark_account` will return the StarkPublicKey of registered account by the wallet. #### Flow #### Interface: ```typescript // request interface StarkAccountRequest { id: number; jsonrpc: "2.0"; method: "stark_account"; params: { layer: string; application: string; index: string; }; } // response interface StarkAccountResponse { id: number; jsonrpc: "2.0"; result: { starkPublicKey: string; }; } ``` #### Example: Please notice that the starkKey in the test vectors are not derived from the path. This will be corrected. Example with index `0` ```json // request { "id": 1, "jsonrpc": "2.0", "method": "stark_account", "params": { "layer": "starkex", "application": "starkexdvf", "index": "0" } } // response { "id": 1, "jsonrpc": "2.0", "result": { "starkPublicKey":"0x59a543d42bcc9475917247fa7f136298bb385a6388c3df7309955fcb39b8dd4", } } ``` Example with index `1` ```json // request { "id": 1, "jsonrpc": "2.0", "method": "stark_account", "params": { "layer": "starkex", "application": "starkexdvf", "index": "1" } } // response { "id": 1, "jsonrpc": "2.0", "result": { "starkPublicKey": "0x397e76d1667c4454bfb83514e120583af836f8e32a516765497823eabe16a3f", } } ``` ### Register Account The method `stark_register` will register the active Ethereum wallet to the StarkExchange and return the transaction hash of the submitted registration on-chain. #### Flow #### Interface: ```typescript // request interface StarkRegisterRequest { id: number; jsonrpc: "2.0"; method: "stark_register"; params: { contractAddress: string; starkPublicKey: string; operatorSignature: string; }; } // response interface StarkRegisterResponse { id: number; jsonrpc: "2.0"; result: { txhash: string; }; } ``` #### Example: ```json // request { "id": 1, "jsonrpc": "2.0", "method": "stark_register", "params": { "contractAddress": "0xC5273AbFb36550090095B1EDec019216AD21BE6c", "starkPublicKey": "0x59a543d42bcc9475917247fa7f136298bb385a6388c3df7309955fcb39b8dd4", "operatorSignature": "0xae50f29764c96ff5d1554f1d0605bdb992a62700eb8a0b2ffd711da6d6fd90781dbfbb8918c98c15e9fd6251ad89d55e30c20060cf300b51929129726718b6711c" }, } // response { "id": 1, "jsonrpc": "2.0", "result": { "txhash": "0xbcbb3845cfa1252e43228c76745c1366ccf43b70e01ab0f81d3f166ac045e627" } } // context { "privateKey": "0x9a983cb3d832fbde5ab49d692b7a8bf5b5d232479c99333d0fc8e1d21f1b55b6", "address": "0x6Fac4D18c912343BF86fa7049364Dd4E424Ab9C0", "nonce": "0" } ``` ### Deposit Asset The method `stark_deposit` will request a deposit of an asset into provided vaultId and will return the transaction hash of the submitted deposit on-chain. #### Flow #### Interface: ```typescript // request interface StarkDepositRequest { id: number; jsonrpc: "2.0"; method: "stark_deposit"; params: { contractAddress: string; starkPublicKey: string; vaultId: string; token: Token; quantizedAmount: string; }; } // response interface StarkDepositResponse { id: number; jsonrpc: "2.0"; result: { txhash: string; }; } ``` #### Example: Example with token type `ERC20` ```json // request { "id": 1, "jsonrpc": "2.0", "method": "stark_deposit", "params": { "contractAddress": "0xC5273AbFb36550090095B1EDec019216AD21BE6c", "starkPublicKey": "0x59a543d42bcc9475917247fa7f136298bb385a6388c3df7309955fcb39b8dd4", "vaultId": "15", "token": { "quantum": "1", "tokenAddress": "0x89b94e8C299235c00F97E6B0D7368E82d640E848" }, "quantizedAmount": "10" } } // response { "id": 1, "jsonrpc": "2.0", "result": { "txhash": "0xffe915f46a9953e486cfbd1a6d581da69ce122cc31e49500a8b8422e61bd2374" } } // context { "privateKey": "0x9a983cb3d832fbde5ab49d692b7a8bf5b5d232479c99333d0fc8e1d21f1b55b6", "address": "0x6Fac4D18c912343BF86fa7049364Dd4E424Ab9C0", "tokenId": "0x129b06238c61f34d4c4ffb5ad469c7b24001810d876f78e4f1ae0010f882315", "nonce": "2" } ``` Example with token type `ETH` ```json // request { "id": 1, "jsonrpc": "2.0", "method": "stark_deposit", "params": { "contractAddress": "0x3EaD5582681dA76d0BF28E0D241277A5D797E293", "starkPublicKey": "0x59a543d42bcc9475917247fa7f136298bb385a6388c3df7309955fcb39b8dd4", "vaultId": "15", "token": { "quantum": "2" } "quantizedAmount": "20" } } // response { "id": 1, "jsonrpc": "2.0", "result": { "txhash": "0x8e450d96e4b91b2f3a5ef0baf3cb30bab579bcf5e781129594f62a5a3bd091de" } } // context { "privateKey": "0x9a983cb3d832fbde5ab49d692b7a8bf5b5d232479c99333d0fc8e1d21f1b55b6", "address": "0x6Fac4D18c912343BF86fa7049364Dd4E424Ab9C0", "tokenId": "0x1169799835a38e104a8147cf0380d0294d62273c2250343d71f4ea9aa397ba7", "nonce": "6" } ``` ### Deposit Cancel The method `stark_depositCancel` will request a cancelation of a deposit made to the contract on-chain and will return the transaction hash of the submitted deposit cancelation on-chain. #### Flow #### Interface: ```typescript // request interface StarkDepositCancelRequest { id: number; jsonrpc: "2.0"; method: "stark_depositCancel"; params: { contractAddress: string; starkPublicKey: string; vaultId: string; token: Token; }; } // response interface StarkDepositCancelResponse { id: number; jsonrpc: "2.0"; result: { txhash: string; }; } ``` #### Example: Example with token type `ERC20` ```json // request { "id": 1, "jsonrpc": "2.0", "method": "stark_depositCancel", "params": { "contractAddress": "0xC5273AbFb36550090095B1EDec019216AD21BE6c", "starkPublicKey": "0x59a543d42bcc9475917247fa7f136298bb385a6388c3df7309955fcb39b8dd4", "vaultId": "15", "token": { "quantum": "1", "tokenAddress": "0x89b94e8C299235c00F97E6B0D7368E82d640E848" }, } } // response { "id": 1, "jsonrpc": "2.0", "result": { "txhash": "0xd5f57792eb476382f6bd2bd576c9bc1b85eae8112af912df25e713e5bda377ee" }, } // context { "privateKey": "0x9a983cb3d832fbde5ab49d692b7a8bf5b5d232479c99333d0fc8e1d21f1b55b6", "address": "0x6Fac4D18c912343BF86fa7049364Dd4E424Ab9C0", "tokenId": "0x129b06238c61f34d4c4ffb5ad469c7b24001810d876f78e4f1ae0010f882315", "nonce": "3" } ``` ### Deposit Reclaim The method `stark_depositReclaim` will request a reclaim of a canceled deposit made to the contract on-chain and will return the transaction hash of the submitted deposit reclaim on-chain. #### Flow #### Interface: ```typescript // request interface StarkDepositReclaimRequest { id: number; jsonrpc: "2.0"; method: "stark_depositReclaim"; params: { contractAddress: string; starkPublicKey: string; vaultId: string; token: Token; }; } // response interface StarkDepositCancelResponse { id: number; jsonrpc: "2.0"; result: { txhash: string; }; } ``` #### Example: Example with token type `ERC20` ```json // request { "id": 1, "jsonrpc": "2.0", "method": "stark_depositReclaim", "params": { "contractAddress": "0xC5273AbFb36550090095B1EDec019216AD21BE6c", "starkPublicKey": "0x59a543d42bcc9475917247fa7f136298bb385a6388c3df7309955fcb39b8dd4", "vaultId": "15", "token": { "quantum": "1", "tokenAddress": "0x89b94e8C299235c00F97E6B0D7368E82d640E848" }, }, } // response { "id": 1, "jsonrpc": "2.0", "result": { "txhash": "0x745b0ae5403af8b5e5ec4a6db3c0951dc127019652af63001d00e5c6f436f500" }, } // context { "privateKey": "0x9a983cb3d832fbde5ab49d692b7a8bf5b5d232479c99333d0fc8e1d21f1b55b6", "address": "0x6Fac4D18c912343BF86fa7049364Dd4E424Ab9C0", "tokenId": "0x129b06238c61f34d4c4ffb5ad469c7b24001810d876f78e4f1ae0010f882315", "nonce": "4" } ``` ### Transfer Asset This method `stark_transfer` will request an asset transfer off-chain and will return a stark signature approved by the wallet. #### Flow #### Interface: ```typescript // request interface StarkTransferRequest { id: number; jsonrpc: "2.0"; method: "stark_transfer"; params: { contractAddress: string; from: TransferParams; to: TransferParams; token: Token; quantizedAmount: string; nonce: string; expirationTimestamp: string; }; } // response interface StarkTransferResponse { id: number; jsonrpc: "2.0"; result: { starkSignature: string; }; } // TransferParams interface TransferParams { starkPublicKey: string; vaultId: string; } ``` #### Example: Example with token type `ERC20` ```json // request { "id": 1, "jsonrpc": "2.0", "method": "stark_transfer", "params": { "contractAddress": "0xC5273AbFb36550090095B1EDec019216AD21BE6c", "from": { "starkPublicKey": "0x59a543d42bcc9475917247fa7f136298bb385a6388c3df7309955fcb39b8dd4", "vaultId": "34" }, "to": { "starkPublicKey": "0x5fa3383597691ea9d827a79e1a4f0f7949435ced18ca9619de8ab97e661020", "vaultId": "21" }, "token": { "quantum": "", "tokenAddress": "" }, "quantizedAmount": "2154549703648910716", "nonce": "1", "expirationTimestamp": "438953" } } // response { "id": 1, "jsonrpc": "2.0", "result": { "starkSignature": "0x735fffa9bf371ca294c5f74c15b434684cfe7e9e0500e6a59589ef05c1fce131593b9496b7572f7bae8028c66405e3d76132723affdb5e4e76aadb8c2ae04f" } } // context { "transfer_order": { "message_hash": "0x6366b00c218fb4c8a8b142ca482145e8513c78e00faa0de76298ba14fc37ae7", "private_key": "0x7cc2767a160d4ea112b436dc6f79024db70b26b11ed7aa2cb6d7eef19ace703", "tokenId": "0x3003a65651d3b9fb2eff934a4416db301afd112a8492aaf8d7297fc87dcd9f4", "order_id": "7162605823528514760" } } ``` ### Create Limit Order This method `stark_createOrder` will request the creation of a limit order off-chain and will return a stark signature approved by the wallet. #### Flow #### Interface: ```typescript // request interface StarkCreateOrderRequest { id: number; jsonrpc: "2.0"; method: "stark_createOrder"; params: { contractAddress: string; starkPublicKey: string; sell: OrderParams; buy: OrderParams; nonce: string; expirationTimestamp: string; }; } // response interface StarkCreateOrderResponse { id: number; jsonrpc: "2.0"; result: { starkSignature: string; }; } // OrderParams interface OrderParams { vaultId: string; token: Token; quantizedAmount: string; } ``` #### Example: Example with token type `ERC20` ```json // request { "id": 1, "jsonrpc": "2.0", "method": "stark_createOrder", "params": { "contractAddress": "0xC5273AbFb36550090095B1EDec019216AD21BE6c", "starkPublicKey": "0x77a3b314db07c45076d11f62b6f9e748a39790441823307743cf00d6597ea43", "sell": { "vaultId": "21", "token": { "quantum": "", "tokenAddress": "" }, "quantizedAmount": "2154686749748910716", }, "buy": { "vaultId": "27", "token": { "quantum": "", "tokenAddress": "" }, "quantizedAmount": "1470242115489520459", }, "nonce": "0", "expiration_timestamp": "438953" } } // response { "id": 1, "jsonrpc": "2.0", "result": { "starkSignature": "0x173fd03d8b008ee7432977ac27d1e9d1a1f6c98b1a2f05fa84a21c84c44e8821f2c44a7798f55192f153b4c48ea5c1241fbb69e6132cc8a0da9c5b62a4286e" } } // context { "token_sell": "0x5fa3383597691ea9d827a79e1a4f0f7989c35ced18ca9619de8ab97e661020", "token_buy": "0x774961c824a3b0fb3d2965f01471c9c7734bf8dbde659e0c08dca2ef18d56a", "message_hash": "0x397e76d1667c4454bfb83514e120583af836f8e32a516765497823eabe16a3f", "private_key": "0x3c1e9550e66958296d11b60f8e8e7a7ad990d07fa65d5f7652c4a6c87d4e3cc", "order_id": "4142879348967097428" } ``` ### Offchain Withdraw Asset (No Signature Involved) #### Flow ### Withdraw Asset This method `stark_withdrawal` will request the withdrawal of an asset on-chain and will return the transaction hash of the submitted withdrawal on-chain. #### Flow #### Interface: ```typescript // request interface StarkWithdrawalRequest { id: number; jsonrpc: "2.0"; method: "stark_withdrawal"; params: { contractAddress: string; token: Token; }; } // response interface StarkWithdrawalResponse { id: number; jsonrpc: "2.0"; result: { txhash: string; }; } ``` #### Example: Example with token type `ERC20` ```json // request { "id": 1, "jsonrpc": "2.0", "method": "stark_withdrawal", "params": { "contractAddress": "0x48C5c08aD49Fc8Dc657cD3b2964c8db187FB0481", "token": { "quantum": "1", "tokenAddress": "0x0a7183b53E571771A0e93fda170F2F0549C1C112" } } } // response { "id": 1, "jsonrpc": "2.0", "result": { "txhash": "0x980a05d8199bad8c6e2012ed587007a094477849c559bdeb45256c88bd29de11" } } // context { "privateKey": "0x9a983cb3d832fbde5ab49d692b7a8bf5b5d232479c99333d0fc8e1d21f1b55b6", "address": "0x6Fac4D18c912343BF86fa7049364Dd4E424Ab9C0", "tokenId": "0x29673464669bbf2b94a5b83997ab37083a436ab0e14eb7f3bbae26f6acfb0c3", "nonce": "47" } ``` Example with token type `ETH` ```json // request { "id": 1, "jsonrpc": "2.0", "method": "stark_withdrawal", "params": { "contractAddress": "0xBBC8C5481d1C992D8a974deC23C7CE93D679c5C9", "token": { "quantum": "2" } } } // response { "id": 1, "jsonrpc": "2.0", "result": { "txhash": "0x9302e5cca1df63755574d59653cee56f5a1abdae2e68f9802b3103d686eca9b1" } } // context { "privateKey": "0x9a983cb3d832fbde5ab49d692b7a8bf5b5d232479c99333d0fc8e1d21f1b55b6", "address": "0x6Fac4D18c912343BF86fa7049364Dd4E424Ab9C0", "tokenId": "0x1169799835a38e104a8147cf0380d0294d62273c2250343d71f4ea9aa397ba7", "nonce": "49" } ``` ### Full Withdrawal Vault This method `stark_fullWithdrawal` will request the full withdrawal of an off-chain vault and will return the transaction hash of the submitted full withdrawal call on-chain. #### Interface: ```typescript // request interface StarkFullWithdrawalRequest { id: number; jsonrpc: "2.0"; method: "stark_fullWithdrawal"; params: { contractAddress: string; vaultId: string; }; } // response interface StarkFullWithdrawalResponse { id: number; jsonrpc: "2.0"; result: { txhash: string; }; } ``` #### Example: ```json // request { "id": 1, "jsonrpc": "2.0", "method": "stark_fullWithdrawal", "params": { "contractAddress": "0x7a402427ef5Ae1489f78457c4086c4AFC743C0A6", "vaultId": "3" } } // response { "id": 1, "jsonrpc": "2.0", "result": { "txhash": "0xfc83a1a6a7461d185d6d44e5e474f1c764a9486afcc83aeaeb204a63a42032ad" } } // context { "privateKey": "0x9a983cb3d832fbde5ab49d692b7a8bf5b5d232479c99333d0fc8e1d21f1b55b6", "address": "0x6Fac4D18c912343BF86fa7049364Dd4E424Ab9C0", "starkPublicKey": "0x59a543d42bcc9475917247fa7f136298bb385a6388c3df7309955fcb39b8dd4", "nonce": "27" } ``` ### Freeze Contract This method `stark_freeze` will request the freeze of the contract and will return the transaction hash of the submitted freeze call on-chain. #### Interface: ```typescript // request interface StarkFreezeRequest { id: number; jsonrpc: "2.0"; method: "stark_freeze"; params: { contractAddress: string; vaultId: string; }; } // response interface StarkFreezeResponse { id: number; jsonrpc: "2.0"; result: { txhash: string; }; } ``` #### Example: ```json // request { "id": 1, "jsonrpc": "2.0", "method": "stark_freeze", "params": { "contractAddress": "0x7a402427ef5Ae1489f78457c4086c4AFC743C0A6", "vaultId": "3" } } // response { "id": 1, "jsonrpc": "2.0", "result": { "txhash": "0xc8a0c0ed72ae6c563b323e9add29cfd93d5cb969de6ca35977177a332b04ce3e" } } // context { "privateKey": "0x9a983cb3d832fbde5ab49d692b7a8bf5b5d232479c99333d0fc8e1d21f1b55b6", "address": "0x6Fac4D18c912343BF86fa7049364Dd4E424Ab9C0", "starkPublicKey": "0x59a543d42bcc9475917247fa7f136298bb385a6388c3df7309955fcb39b8dd4", "nonce": "28" } ``` ### Verify Escape This method `stark_verifyEscape` will provide the proof for the escape. #### Interface: ```typescript // request interface StarkVerifyEscapeRequest { id: number; jsonrpc: "2.0"; method: "stark_verifyEscape"; params: { contractAddress: string; proof: string[]; }; } // response interface StarkVerifyEscapeResponse { id: number; jsonrpc: "2.0"; result: { txhash: string; }; } ``` #### Proof Example: ```typescript [ "3533772073355067386033650359960199886012348633125689077279705636794314562180", "31427047970345673757012126699659538045618813024120395264836621949253850585344", "38422745836957834608116983367750831521285445816911862565695276884592698042000", "304315052591732045568", "5021233070011740680532843509854937350086963617043533754858001929304304713908", "32155736778989711246139641295624962637243870965958022462125972080652534497792", "13203959379647270763737907984337877465408570052216961167644315262077751997553", "99178380692411026472028033088507445806378642651740782294144737044337542025216", "41096826960538513883254143407052656057117074000340021784418716174389659231557", "20894025957091018130975914799136784612345618353099487610481793900037168670976", "18251823945812275100891062507945043843331907738106195624847294624094147801123", "39788236641746273681192219618701072958562915240402801216846182424706903180288", "29328978571202094277527814781829369302783146287684985903839654175183092286374", "9547971168496630027159085375284032591104304239243265061311842428441357281536", "15367341209460484926915011706811990839742029990620754383292727578245401624839", "65863152087527643630760979846245293912224050302277023183218584961374256473088", "43031299876771822810994762175630819583995224518603284296805054254223961987062", "102281286572436279970261502605950462502557134758469363167896674198581213242368", "7930124177266922047851329391857930031698461026641690743138123663250527601796", "94058288424055442399218689458939771903324651137098105000531795197414869991168", "30461703567431901577778719744785677768536102127535135100125713709474738922512", "55331818438107551168030656993070349294087523151615815677720278987041386950912", "28681604752224169308580973149418512744016796252869824801310913293671737342293", "27521501820137038434738933575628806610034948832359813194967361110953896621312", "33729936254926360650636714077882563458104590866223198957588813314090573553860", "112981458493347365888441670126910368385171040632295426831013205661799583415296", "33601314734054759151382622455835909471570339896179484333018895130522513956260", "84941492823024391113008253711595948522919774265120122463208702935316561081344", "27913283727448756400817779012588722060643535835072585846926497602945764628593", "23843911218911412616022416346428858191238510945612840753080524741417649587456", "35945622951149974419867838457132791983076054314545970292378049981584032392327", "30526205198906124515354401302344777447408684706134038747455211082874933453568", "44943412516923682085451484496057470734832423506336154374918234132764926432707", "64041238232594015259921628354643855001962847980677834605212332991892987377664", "13394970471139228377399803936764986625091017791296479677942820253062311367364", "34477241657478249881550035139519112850573475234724503688456977867404775809536", "29438076154735896033386510787429831760392375746397204767474333341701915038919", "10347606627708123623040635996593299256196617520484276868672032987030762903040", "40697084830497913197394706657333957881766253128085960299480949263625057610135", "46539515800707539708234594748732221433715112472560941969042733479345935926016", "16266644257445898617086424067253231336010385905463419353091802271176729381856", "16288819337598860629354525488655504462574232099339502272212252771297765976832", "28784945115320960027442650084553723585794508108800233678015204514673809771269", "43892265237308750997829104006565188613689461670667908749637919186266234350336", "3986684324777701816440069390694015755401164532551631978290960508949195952038", "19521914162219056769766122401467852865588227164196684652067658031051645683200", "4657046583835288822126146833192673534123226395676393574986818311324459489520", "32532653804192056556272916446313678436603798283166167241548288061142643836416", "46337768468682088182788920139011125681887348137932701819108794696212267130947", "58824843658320398094491758031525672321940180087261510954884445377439072925184", "12852650973639229721209089235204012522725594689578895148437974908713080000321", "99364620149868661728794557500330422751055780487615114449038458717507354209536", "31412892328235071562931764610529934230196223502592816985738914139690571012720", "81013629803750084947245859900072508003943959638490472747176867751191040466944", "12659062279978089468717144866143166281458000423982267920905919631130677072950", "28859199300704957830718890034029954071805265170736044481526763541858289254144", "48871986027267510575997989852177359687673196717827213669578989930113848393255", "56119021301710872651140058128986502359476670265305617271094936484643873570048", "42447806982791576410322307302927692499820798911999013185911112248463099715509", "71598509676411295040818950593527979651579193578026398295119905890562035982336", "54607073721455838458522144590696757378618515980857630832010337670906155697856", "22525094588027648297026725165962366304742977108994408456888711917717809754112", "26227470597097234619999706140230992582522322644195611813271701027271327789392", "72258113366688583729537508425108140643566031509852577825772231943167636480768", "55263259852153816901105384603537140790166850678307602891793039108621745354482", "18911568929430605252229058363391538697164139716358235682392853031567287598592", "43393832852808973725776540778763822735773032700526968097104145902190708721906", "98193016811778819999296519910676770383260671613165743272711778040115701214208", "30234276729403841666591301602057158477170243770081146829902084961432903424432", "66588869103233125697138455915048748559634675333045113002959081750047419538432", "16256690868972993320553588836619957753922937561588711184975394157870786938337", "47404132813467723873749319198853221000317107546617540626263770495344684789760", "47492695803704426995925006548945632477876342811647241506620188891292026910454d59382415459231770651674570800404195153706389222417548955439914935238752731904", "44257961116472514577570319949543081622868888821524063961470613156517112075472", "574995603456", ]; ``` ### Escape This method `stark_escape` will request the escape of a vault from a frozen contract and will return the transaction hash of the submitted escape. #### Interface: ```typescript // request interface StarkEscapeRequest { id: number; jsonrpc: "2.0"; method: "stark_escape"; params: { contractAddress: string; starkPublicKey: string; vaultId: string; token: Token; quantizedAmount: string; }; } // response interface StarkEscapeResponse { id: number; jsonrpc: "2.0"; result: { txhash: string; }; } ``` #### Example: ```json // request { "id": 1, "jsonrpc": "2.0", "method": "stark_escape", "params": { "contractAddress": "0x7a402427ef5Ae1489f78457c4086c4AFC743C0A6", "starkPublicKey": "0x59a543d42bcc9475917247fa7f136298bb385a6388c3df7309955fcb39b8dd4", "token": { "quantum": "1000", "tokenAddress": "0x485c1432F26CAc821Cf8070417Fa0EFeAB19Df83" }, "quantizedmount": "8233298795789816600" } } // response { "id": 1, "jsonrpc": "2.0", "result": { "txhash": "0xd1e5a3b1bf7c4da9a4f12646cfc15b294e228eafe4225e9623927189fb8c65b2" } } // context { "privateKey": "0x9a983cb3d832fbde5ab49d692b7a8bf5b5d232479c99333d0fc8e1d21f1b55b6", "address": "0x6Fac4D18c912343BF86fa7049364Dd4E424Ab9C0", "tokenId": "0x258061c0a4e86837f975b5a5df7c5b073f40a22d169cc10f84c6de33c18b73d", "nonce": "30" } ``` ## Shared Interfaces ### Token This specification expects tokens to be defined by the following interface ```typescript interface Token type: string; data: ETHTokenData | ERC20TokenData | ERC721TokenData; } ``` Token.data is conditional on the Token.type, examples: For type `ETH` ```typescript interface ETHTokenData { quantum: string; } ``` For type `ERC20` ```typescript interface ERC20TokenData { quantum: string; tokenAddress: string; } ``` For type `ERC721` ```typescript interface ERC721TokenData { tokenId: string; tokenAddress: string; } ``` ## Parameter Types | Name | Type | Bytes | | ------------------- | ------- | ----- | | contractAddress | bytes | 20 | | index | uint32 | 4 | | starkPublicKey | bytes | 32 | | operatorSignature | bytes | 65 | | txhash | bytes | 20 | | vaultId | uint32 | 4 | | quantum | uint256 | 32 | | tokenAddress | bytes | 20 | | quantizedAmount | uint64 | 8 | | nonce | uint32 | 4 | | expirationTimestamp | uint32 | 4 | | starkSignature | bytes | 64 | | proof | bytes | n | > n = variable size ## StarkWare key derivation Starkware keys are derived with the following BIP43-compatible derivation path, with direct inspiration from BIP44: ``` m / purpose' / layer' / application' / eth_address_1' / eth_address_2' / index ``` where: * `m` - is the seed * `purpose` - will be a number we define for this specific scheme * `layer` - to allow other companies in the future to use this scheme if they want. will probably be the last 31 bits of h(starkware) * `application` - to allow different applications. the last 31 bits of h(starkexdvf) * `eth_address_1 / eth_address_2` - will be the first and second 31 lowest bits of the eth_address the user is currently using to interact with the exchange. * `index` - to allow multiple keys per eth_address. The key derivation should follow the following algorithm ``` N = secp256k1 curve order n = stark252 curve order path = stark derivation path BIP32() = Official BIP-0032 derivation function on secp256k1 hash = SHA256 i = 0 root_key = BIP32(path) while True: key = hash(root_key|i) if (key < (N - (N % n))): return key % n i++ ``` This algorithm has been defined to maintain efficiency on existing restricted devices. Nota Bene: At each round, the probability for a key to be greater than (N - (N % n)) is < 2^(-5). ## Testing Environment All Ethereum keys were derived with the following BIP39-compatible seed phrase: ``` abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about ``` For testing purposes, the same seed phrase for both operator and user and the following parameters are used: * Operator Address is at index 0 * User Address is at index 1 * Contract Address is at address 0x9c693c9b1c04ccd9f9249a02b301ba23d3c5cd82 (ropsten)

Import from clipboard

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template is not available.
Upgrade
All
  • All
  • Team
No template found.

Create custom template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

How to use Slide mode

API Docs

Edit in VSCode

Install browser extension

Get in Touch

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Upgrade to Prime Plan

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

No updates to save
Compare with
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Upgrade

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Upgrade

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully