-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'devnet' into testdevnet
- Loading branch information
Showing
92 changed files
with
6,746 additions
and
3,242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule fuel-graphql-docs
updated
40 files
Submodule fuel-specs
updated
21 files
+15 −0 | .github/pull_request_template.md | |
+1 −0 | .gitignore | |
+4 −0 | spell-check-custom-words.txt | |
+2 −0 | src/SUMMARY.md | |
+118 −11 | src/abi/argument-encoding.md | |
+11 −5 | src/fuel-vm/index.md | |
+40 −34 | src/fuel-vm/instruction-set.md | |
+1 −1 | src/identifiers/utxo-id.md | |
+1 −0 | src/index.md | |
+10 −7 | src/protocol/block-header.md | |
+1 −0 | src/protocol/index.md | |
+64 −0 | src/protocol/relayer.md | |
+32 −14 | src/protocol/tx-validity.md | |
+20 −18 | src/tx-format/consensus_parameters.md | |
+1 −0 | src/tx-format/index.md | |
+12 −19 | src/tx-format/input.md | |
+2 −4 | src/tx-format/output.md | |
+12 −12 | src/tx-format/policy.md | |
+123 −53 | src/tx-format/transaction.md | |
+38 −0 | src/tx-format/upgrade_purpose.md | |
+1 −1 | src/tx-format/witness.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
--- | ||
title: Contract Quickstart | ||
category: Contract Quickstart | ||
parent: | ||
label: All Guides | ||
link: /guides | ||
--- | ||
|
||
# Smart Contract Quickstart | ||
|
||
Getting started with Fuel as a smart contract developer is as simple as: | ||
|
||
1. [Installing](#installation) `fuelup` | ||
2. [Generating a counter contract](#generating-a-counter-contract) | ||
3. [Building and deploying the contract](#building-and-deploying-the-contract) | ||
|
||
## Installation | ||
|
||
<TextImport | ||
file="../installation/index.mdx" | ||
comment="install_fuelup" | ||
commentType="{/*" | ||
/> | ||
|
||
<CodeImport | ||
file="../installation/index.mdx" | ||
comment="install_fuelup_command" | ||
commentType="{/*" | ||
lang="sh" | ||
trim="true" | ||
/> | ||
|
||
<TextImport | ||
file="../counter-dapp/building-a-smart-contract.mdx" | ||
comment="install_help" | ||
commentType="{/*" | ||
/> | ||
|
||
<TextImport | ||
file="../installation/index.mdx" | ||
comment="install_VSCode_extensions" | ||
commentType="{/*" | ||
/> | ||
|
||
## Generating a counter contract | ||
|
||
Run the command below to generate a counter contract in Sway: | ||
|
||
```sh | ||
forc template --template-name counter counter-contract | ||
``` | ||
|
||
The contract will be in the `src/main.sw` file. | ||
|
||
<TextImport | ||
file="../counter-dapp/building-a-smart-contract.mdx" | ||
comment="forc_new" | ||
commentType="{/*" | ||
/> | ||
|
||
## Building and deploying the contract | ||
|
||
To build a contract, inside the `counter-contract` folder you can run: | ||
|
||
```sh | ||
forc build | ||
``` | ||
|
||
To deploy the contract to the testnet, you can run: | ||
|
||
```sh | ||
forc deploy --node-url https://devnet.fuel.network/v1/graphql | ||
``` | ||
|
||
<TextImport | ||
file="../counter-dapp/building-a-smart-contract.mdx" | ||
comment="forc_wallet" | ||
commentType="{/*" | ||
/> | ||
|
||
## Next Steps | ||
|
||
Ready to learn more? Check out the following resources: | ||
|
||
- Learn the step-by-step instructions for how to build a full-stack [counter contract dapp](/guides/counter-dapp) | ||
- Build a full-stack marketplace dapp with the [Intro to Sway](/guides/intro-to-sway) guide | ||
- Try building with [Predicates](/guides/intro-to-predicates) | ||
- Read the [Sway docs](/docs/sway) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
--- | ||
title: Building a Frontend | ||
category: Quickstart | ||
category: Counter Dapp | ||
parent: | ||
label: All Guides | ||
link: /guides | ||
|
@@ -19,17 +19,9 @@ To build a frontend application for the counter contract, we'll do the following | |
|
||
## Install the Fuel Browser Wallet | ||
|
||
> Make sure your browser is using the latest version of chromium. | ||
Our frontend application will allow users to connect with a wallet, so you'll need to have a browser wallet installed. | ||
|
||
<ConditionalContent versionSet={props.versionSet} showForVersions={['default', 'nightly']}> | ||
Before going to the next steps, install the Fuel Wallet [here](https://chrome.google.com/webstore/detail/fuel-wallet/dldjpboieedgcmpkchcjcbijingjcgok). | ||
|
||
If you have previously installed the wallet, make sure you have updated to the latest version. | ||
</ConditionalContent> | ||
|
||
Once you've setup your wallet, click the "Faucet" button in the wallet to get some testnet tokens. | ||
You can use the [Fuel Wallet](https://chromewebstore.google.com/detail/fuel-wallet/dldjpboieedgcmpkchcjcbijingjcgok), [Fuelet](https://fuelet.app/), or [Metamask](https://metamask.io/). | ||
|
||
## Initialize a React project | ||
|
||
|
@@ -90,17 +82,12 @@ action={{ | |
}} | ||
/> | ||
|
||
<ConditionalContent versionSet={props.versionSet} showForVersions={['default', 'nightly']}> | ||
|
||
```sh | ||
npm install fuels@0.82.0 @fuels/react@0.18.0 @fuels/connectors@0.2.2 @tanstack/react-query@5.28.9 | ||
npm install fuels @fuels/react @fuels/connectors @tanstack/react-query | ||
``` | ||
|
||
</ConditionalContent> | ||
|
||
## Generate contract types | ||
|
||
<ConditionalContent versionSet={props.versionSet} showForVersions={['default', 'nightly']}> | ||
The `fuels init` command generates a `fuels.config.ts` file that is used by the SDK to generate contract types. | ||
Use the `contracts` flag to define where your contract folder is located, and the `output` flag to define where you want the generated files to be created. | ||
|
||
|
@@ -115,7 +102,7 @@ action={{ | |
/> | ||
|
||
```sh | ||
npx fuels@0.82.0 init --contracts ../counter-contract/ --output ./src/sway-api | ||
npx fuels init --contracts ../counter-contract/ --output ./src/sway-api | ||
``` | ||
|
||
Now that you have a `fuels.config.ts` file, you can use the `fuels build` command to rebuild your contract and generate types. | ||
|
@@ -133,7 +120,7 @@ action={{ | |
/> | ||
|
||
```sh | ||
npx fuels@0.82.0 build | ||
npx fuels build | ||
``` | ||
|
||
A successful process should print and output like the following: | ||
|
@@ -145,16 +132,12 @@ Generating types.. | |
🎉 Build completed successfully! | ||
``` | ||
|
||
> If you're having any issues with this part, try adding `useBuiltinForc: false,` to your `fuels.config.ts` config file to make sure it's using the same version of `forc` as your default toolchain. | ||
Now you should be able to find a new folder `fuel-project/frontend/src/sway-api`. | ||
</ConditionalContent> | ||
|
||
## Modify the App | ||
|
||
Inside the `frontend/src` folder let's add code that interacts with our contract. | ||
|
||
<ConditionalContent versionSet={props.versionSet} showForVersions={['default', 'nightly']}> | ||
Because we'll be using `@fuels/react`, first we need to wrap our app with the `FuelProvider` component. | ||
|
||
Add the imports below to the top of your `frontend/src/index.tsx` file and setup a query client: | ||
|
@@ -169,10 +152,10 @@ action={{ | |
/> | ||
|
||
<CodeImport | ||
file="../../examples/quickstart/frontend/src/index.tsx" | ||
file="../../examples/counter-dapp/frontend/src/index.tsx" | ||
lang="tsx" | ||
lineStart="6" | ||
lineEnd="14" | ||
lineEnd="15" | ||
/> | ||
|
||
Next, modify your `frontend/src/index.tsx` file to wrap the `App` component with the `FuelProvider` and `QueryClientProvider` components. | ||
|
@@ -182,18 +165,17 @@ id="fuel-wallet-provider" | |
action={{ | ||
name: 'modifyFile', | ||
filepath: 'guides-testing/fuel-project/frontend/src/index.tsx', | ||
atLine: 21, | ||
removeLines: [21], | ||
atLine: 22, | ||
removeLines: [22], | ||
}} | ||
/> | ||
|
||
<CodeImport | ||
file="../../examples/quickstart/frontend/src/index.tsx" | ||
file="../../examples/counter-dapp/frontend/src/index.tsx" | ||
lang="tsx" | ||
lineStart="21" | ||
lineEnd="33" | ||
lineStart="22" | ||
lineEnd="35" | ||
/> | ||
</ConditionalContent> | ||
|
||
Next, change the file `fuel-project/frontend/src/App.tsx` to: | ||
|
||
|
@@ -205,12 +187,10 @@ action={{ | |
}} | ||
/> | ||
|
||
<ConditionalContent versionSet={props.versionSet} showForVersions={['default', 'nightly']}> | ||
<CodeImport | ||
file="../../examples/quickstart/frontend/src/App.tsx" | ||
file="../../examples/counter-dapp/frontend/src/App.tsx" | ||
lang="tsx" | ||
/> | ||
</ConditionalContent> | ||
|
||
Finally, replace the value of the `CONTRACT_ID` variable at the top of your `App.tsx` file with the address of the contract you just deployed. | ||
|
||
|
@@ -221,7 +201,7 @@ action={{ | |
filepath: 'guides-testing/fuel-project/frontend/src/App.tsx', | ||
atLine: 13, | ||
removeLines: [13], | ||
useSetData: ' "0xf2402a4c375550abc8c781bb59761135f88799dcfa81862f8233dfe234894dfe";' | ||
useSetData: ' "0x92073699bd78dac70756a9e0e8bca1c7121c7adc4b90570800f0916fe4ac33dd";' | ||
}} | ||
/> | ||
|
||
|
@@ -253,39 +233,33 @@ Note that the development build is not optimized. | |
To create a production build, use npm run build. | ||
``` | ||
|
||
<ConditionalContent versionSet={props.versionSet} showForVersions={['default', 'nightly']}> | ||
Click the "Connect" button and select "Fuel Wallet Development" to connect your wallet. | ||
Once connected, you should see the counter value and increment button: | ||
Click the "Connect" button and select the wallet you have installed to connect your wallet. | ||
|
||
Once connected, if there are no funds in your wallet, you will see a link to get testnet funds. | ||
|
||
If you have testnet ETH on Fuel, you should see the counter value and increment button: | ||
|
||
<Box.Centered> | ||
![screenshot of the UI](/images/quickstart-frontend.png) | ||
</Box.Centered> | ||
</ConditionalContent> | ||
|
||
## You just built a fullstack dapp on Fuel! ⛽ | ||
|
||
<ConditionalContent versionSet={props.versionSet} showForVersions={['default', 'nightly']}> | ||
[Here is the repo for this project](https://github.com/FuelLabs/docs-hub/tree/master/docs/guides/examples/quickstart). | ||
</ConditionalContent> | ||
[Here is the repo for this project](https://github.com/FuelLabs/docs-hub/tree/master/docs/guides/examples/counter-dapp). | ||
|
||
If you run into any problems, a good first step is to compare your code to this repo and resolve any differences. | ||
|
||
Tweet us [@fuel_network](https://twitter.com/fuel_network) letting us know you just built a dapp on Fuel, you might get invited to a private group of builders, be invited to the next Fuel dinner, get alpha on the project, or something 👀. | ||
|
||
### Updating The Contract | ||
|
||
<ConditionalContent versionSet={props.versionSet} showForVersions={['default', 'nightly']}> | ||
To develop and test faster, we recommend using the [`fuels dev` command](/docs/fuels-ts/fuels-cli/commands/) to start a local node and automatically redeploy and generate types for your contract on each change. | ||
</ConditionalContent> | ||
To develop and test faster, we recommend using the [`fuels dev` command](/docs/fuels-ts/fuels/commands/) to start a local node and automatically redeploy and generate types for your contract on each change. | ||
|
||
Once you're ready to redeploy your contract to the testnet, here are the steps you should take to get your frontend and contract back in sync: | ||
|
||
<ConditionalContent versionSet={props.versionSet} showForVersions={['default', 'nightly']}> | ||
|
||
- In your frontend directory, re-run this command: `npx [email protected] build`. | ||
- In your contract directory, redeploy the contract by running this command and following the same steps as above to sign the transaction with your wallet: `forc deploy --testnet`. | ||
- In your frontend directory, re-run this command: `npx fuels build`. | ||
- In your contract directory, redeploy the contract. | ||
- In your frontend directory, update the contract ID in your `App.tsx` file. | ||
</ConditionalContent> | ||
|
||
## Need Help? | ||
|
||
|
Oops, something went wrong.