Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Change the capitalization of Starknet #941

Merged
merged 1 commit into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/docs/features/contract_factories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
title: Contract Factories
---

Contract factories are now supported by Warp. Contract factories work slightly differently on StarkNet as they do on Ethereum.
To deploy a contract on StarkNet we need to know the class hash of the contract being deployed, this class hash is then passed
Contract factories are now supported by Warp. Contract factories work slightly differently on Starknet as they do on Ethereum.
To deploy a contract on Starknet we need to know the class hash of the contract being deployed, this class hash is then passed
as an argument to the deploy system call. Warp is designed so that the above is hidden from the user and handled internally.
The class hash is calculated offline and inserted into the transpiled Contract factory as a constant.

Note that the contract being deployed by the contract factory will still need to be declared online by the user.

:warning: **Warning**: Warp also supports the use of the salt option i.e `new Contract{salt: salt}()` but because of core differences
between Ethereum and StarkNet the salt value will be truncated from 32 to the 31 most significant bytes.
between Ethereum and Starknet the salt value will be truncated from 32 to the 31 most significant bytes.

The following Solidity contract named example.sol will be used to illustrate the feature:

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/get_around_unsupported_features.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ There is no algorithm to get around unsupported features, in most scenarios it i
- tx.gasprice, tx.origin: No equivalent in Cairo so far.
- Member access of block(block.gaslimit, block.chainid): No equivalent in Cairo. Most of the time won't be needed.
- User defined Errors: No equivalent in Cairo for now.
- Receive function: StarkNet doesn't have a native currency for the protocol so should be rewritten using other approach.
- Receive function: Starknet doesn't have a native currency for the protocol so should be rewritten using other approach.
- Function call options e.g x.f{gas: 10000}(arg1): Most of the options passed are not compatible with Cairo so in most cases can be just removed.

## Unsupported features that developer can get around.
Expand Down
32 changes: 16 additions & 16 deletions docs/docs/getting_started/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Available Commands:
compile [options] <file> Compile cairo files with warplib in the cairo-path
gen_interface [options] <file> Use native Cairo contracts in your Soldity by creating a Solidity interface and a Cairo translation contract for the target Cairo contract
deploy [options] <file> Deploy a warped cairo contract
deploy_account [options] Deploy an account to StarkNet
deploy_account [options] Deploy an account to Starknet
invoke [options] <file> Invoke a function on a warped contract using the Solidity abi
call [options] <file> Call a function on a warped contract using the Solidity abi
install [options] Install the python dependencies required for Warp
Expand Down Expand Up @@ -78,11 +78,11 @@ compile `[options]` `<file...>`:

declare `[options]` `<cairo_contract>`:

--network <network> StarkNet network URL
--network <network> Starknet network URL
--account <account> The name of the account. If not given, the default for the wallet will be used.
--account_dir <account_dir> The directory of the account
--gateway_url <gateway_url> StarkNet gateway URL
--feeder_gateway_url <feeder_gateway_url> StarkNet feeder gateway URL
--gateway_url <gateway_url> Starknet gateway URL
--feeder_gateway_url <feeder_gateway_url> Starknet feeder gateway URL
--wallet <wallet> The name of the wallet, including the python module and wallet class
--max_fee <max_fee> Maximum fee to pay for the transaction
-h, --help display help for command
Expand All @@ -92,9 +92,9 @@ deploy `[options]` `<file...>`:
-d, --debug_info Compile include debug information (default: false)
--inputs <inputs...> Arguments to be passed to constructor of the program as a comma separated list of strings, ints and lists
--use_cairo_abi Use the cairo abi instead of solidity for the inputs (default: false)
--network <network> StarkNet network URL
--gateway_url <gateway_url> StarkNet gateway URL
--feeder_gateway_url <feeder_gateway_url> StarkNet feeder gateway URL
--network <network> Starknet network URL
--gateway_url <gateway_url> Starknet gateway URL
--feeder_gateway_url <feeder_gateway_url> Starknet feeder gateway URL
--no_wallet Do not use a wallet for deployment (default: false)
--wallet <wallet> Wallet provider to use
--account <account> Account to use for deployment
Expand All @@ -106,9 +106,9 @@ deploy_account `[options]`:

--account <account> The name of the account. If not given, the default for the wallet will be used
--account_dir <account_dir> The directory of the account.
--network <network> StarkNet network URL
--gateway_url <gateway_url> StarkNet gateway URL
--feeder_gateway_url <feeder_gateway_url> StarkNet feeder gateway URL
--network <network> Starknet network URL
--gateway_url <gateway_url> Starknet gateway URL
--feeder_gateway_url <feeder_gateway_url> Starknet feeder gateway URL
--wallet <wallet> The name of the wallet, including the python module and wallet class
--max_fee <max_fee> Maximum fee to pay for the transaction.
-h, --help display help for command
Expand All @@ -121,9 +121,9 @@ invoke `[options]` `<file...>`:
--use_cairo_abi Use the cairo abi instead of solidity for the inputs (default: false)
--account <account> The name of the account. If not given, the default for the wallet will be used
--account_dir <account_dir> The directory of the account
--network <network> StarkNet network URL
--gateway_url <gateway_url> StarkNet gateway URL
--feeder_gateway_url <feeder_gateway_url> StarkNet feeder gateway URL
--network <network> Starknet network URL
--gateway_url <gateway_url> Starknet gateway URL
--feeder_gateway_url <feeder_gateway_url> Starknet feeder gateway URL
--wallet <wallet> The name of the wallet, including the python module and wallet class
--max_fee <max_fee> Maximum fee to pay for the transaction
-h, --help display help for command
Expand All @@ -136,9 +136,9 @@ call `[options]` `<file...>`:
--use_cairo_abi Use the cairo abi instead of solidity for the inputs (default: false)
--account <account> The name of the account. If not given, the default for the wallet will be used
--account_dir <account_dir> The directory of the account
--network <network> StarkNet network URL
--gateway_url <gateway_url> StarkNet gateway URL
--feeder_gateway_url <feeder_gateway_url> StarkNet feeder gateway URL
--network <network> Starknet network URL
--gateway_url <gateway_url> Starknet gateway URL
--feeder_gateway_url <feeder_gateway_url> Starknet feeder gateway URL
--wallet <wallet> The name of the wallet, including the python module and wallet class
--max_fee <max_fee> Maximum fee to pay for the transaction
-h, --help display help for command
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/getting_started/inputs-and-outputs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ To use the Cairo ABI to pass inputs, add the `--use_cairo_abi` flag to the `depl

Note that there are some nuances that come with using the Cairo ABI:

- StarkNet does not support Solidity-style strings, so Warp represents strings as dynamic arrays of bytes.
- Starknet does not support Solidity-style strings, so Warp represents strings as dynamic arrays of bytes.
In Cairo ABI, each dynamic array is represented in two parts, the length of the string, and the values of the array
`<arr_len>,<arr[0],arr[1]...arr[n-1]>`.
e.g `ExampleString` -> `13,0x45,0x78,0x61,0x6d,0x70,0x6c,0x65,0x53,0x74,0x72,0x69,0x6e,0x67`
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ sidebar_position: 1

We are excited to announce the second version of Warp, now designed to transpile your Solidity code directly into Cairo.

Warp 1 set out to show that compiling Solidity code into Cairo was possible, and paved the way for developers to access the benefits of StarkNet without needing to master Cairo. Using everything we learned from Warp 1, we have written a new version adding vast improvements to contract efficiency and user experience. In this blog, we will talk through the improvements made to Warp, transpile OpenZeppelin’s ERC20 contract, and describe future plans for the project.
Warp 1 set out to show that compiling Solidity code into Cairo was possible, and paved the way for developers to access the benefits of Starknet without needing to master Cairo. Using everything we learned from Warp 1, we have written a new version adding vast improvements to contract efficiency and user experience. In this blog, we will talk through the improvements made to Warp, transpile OpenZeppelin’s ERC20 contract, and describe future plans for the project.

### Warp 2 vs Warp 1

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/solidity_equivalents/abi_encode.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Due to cairo addresses being able to occupy the whole felt space and solidity's

- When ABI Encoding:
although each data type occupies 32 bytes slot, and a `felt` fits perfectly inside,
an address encoded on a warped contract on StarkNet and later decoded on a L1 will
an address encoded on a warped contract on Starknet and later decoded on a L1 will
cause a `revert` if the address is bigger than 20 bytes. If you wish to decode a cairo address on L1 you must
substitute the address type for `uint256` (or other similar size type) e.g `abi.decode(data, (address))` -> `abi.decode(data, (uint256))`

Expand Down
4 changes: 2 additions & 2 deletions docs/docs/solidity_equivalents/addresses.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
title: Addresses
---

An Ethereum address has a width of 160 bits, while a StarkNet address has a width of 251 bits. To support this change in address size, we had to modified the solc compiler. As a result, Warp's flavour of Solidity uses 256 bits for addresses instead of 160.
An Ethereum address has a width of 160 bits, while a Starknet address has a width of 251 bits. To support this change in address size, we had to modified the solc compiler. As a result, Warp's flavour of Solidity uses 256 bits for addresses instead of 160.

This modification means there are some things to consider when using the address type in Warp.

First, the bounds of an address are not checked at compile time, which can introduce strange behaviour.
The expression `address(uint256(MAX_UINT256))` will not cause any compile time or runtime errors even though the maximum value for addresses is `2**251 - 1`.

Second, the `ecrecover` precompile now returns uint160 and not an address type. The`ecrecover` function does not work with StarkNet's curve, using it to try return a StarkNet address will cause errors. The function will only work when recovering an Ethereum address and returns a `uint160` type and not an `address` type.
Second, the `ecrecover` precompile now returns uint160 and not an address type. The`ecrecover` function does not work with Starknet's curve, using it to try return a Starknet address will cause errors. The function will only work when recovering an Ethereum address and returns a `uint160` type and not an `address` type.
2 changes: 1 addition & 1 deletion docs/docs/solidity_equivalents/inputs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Transcoding Inputs for Starknet Contracts
---

StarkNet contracts, also known as zk-STARK contracts, are a type of smart contract that utilizes zero-knowledge proof technology to provide privacy and security to its users and these contracts are written in [cairo](https://www.cairo-lang.org/docs/) language. Unlike traditional smart contracts written in Solidity, the inputs to a StarkNet contract are structurally different, making it necessary to understand how to interact with them effectively.
Starknet contracts, also known as zk-STARK contracts, are a type of smart contract that utilizes zero-knowledge proof technology to provide privacy and security to its users and these contracts are written in [cairo](https://www.cairo-lang.org/docs/) language. Unlike traditional smart contracts written in Solidity, the inputs to a Starknet contract are structurally different, making it necessary to understand how to interact with them effectively.

[Warp](https://github.com/NethermindEth/warp) is a transpiler tool developed by Nethermind, which is capable of converting Solidity smart contracts into Starknet contracts. However, the input parameters `(calldata)` for the Solidity smart contracts may differ slightly from those required for Starknet contracts written in Cairo. This is due to the differences in the programming languages used and the specific requirements of the respective platforms.

Expand Down
2 changes: 1 addition & 1 deletion docs/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const darkCodeTheme = require('prism-react-renderer/themes/dracula');
/** @type {import('@docusaurus/types').Config} */
const config = {
title: 'Warp 🚀',
tagline: 'Bringing Solidity to StarkNet at warp speed',
tagline: 'Bringing Solidity to Starknet at warp speed',
url: 'https://nethermindeth.github.io/',
baseUrl: '/warp/',
onBrokenLinks: 'throw',
Expand Down
2 changes: 1 addition & 1 deletion docs/i18n/vi/code.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "The name of the project"
},
"homepage.projectDescription": {
"message": "Bringing Solidity to StarkNet at warp speed",
"message": "Bringing Solidity to Starknet at warp speed",
"description": "Description of Warp at homepage"
},
"homepage.documentation.linkLabel": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
title: Contract Factories
---

Contract factories are now supported by Warp. Contract factories work slightly differently on StarkNet as they do on Ethereum.
To deploy a contract on StarkNet we need to know the class hash of the contract being deployed, this class hash is then passed
Contract factories are now supported by Warp. Contract factories work slightly differently on Starknet as they do on Ethereum.
To deploy a contract on Starknet we need to know the class hash of the contract being deployed, this class hash is then passed
as an argument to the deploy system call. Warp is designed so that the above is hidden from the user and handled internally.
The class hash is calculated offline and inserted into the transpiled Contract factory as a constant.

Note that the contract being deployed by the contract factory will still need to be declared online by the user.

:warning: **Warning**: Warp also supports the use of the salt option i.e `new Contract{salt: salt}()` but because of core differences
between Ethereum and StarkNet the salt value will be truncated from 32 to the 31 most significant bytes.
between Ethereum and Starknet the salt value will be truncated from 32 to the 31 most significant bytes.

The following Solidity contract named example.sol will be used to illustrate the feature:

Expand Down
Loading