Skip to content

Merlot21/sway-farm

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

87 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

sway-farm

A simple farming game written in Sway.

Running Locally

Make sure you have fuelup installed and are using the beta-5 toolchain.

Install the Fuel Wallet extension and copy your wallet address. In the frontend folder, open the src/App.tsx file and add the following lines using your Fuel wallet address:

const myWallet = new WalletLocked("fuel123....");
console.log("WALLET:", myWallet.address.toB256());

Run the frontend locally with npm start, and check your console to see your Fuel wallet address in B256 format. Copy this address and update the owner field as shown below in the chainConfig.json file so that your wallet will have test funds.

"initial_state": {
      "coins": [
        {
          "owner": "0x_YOUR_FUEL_WALLET_ADDRESS",
          "amount": "0x00000000FFFFFFFF",
          "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000"
        }
      ]
    },

Run the command below in the main project folder to start a local node.

fuel-core run --db-type in-memory --chain ./chainConfig.json

Next, in the contract folder, run the command below to deploy the contract to your local node.

forc deploy --unsigned

In your wallet, add a network with http://127.0.0.1:4000/graphql and switch to that network.

The contract ID should match the CONTRACT_ID in frontend/src/constants.ts. If you update the contract and the contract ID changes, you must update it here and run the command below in the frontend folder to generate new types.

npx fuels typegen -i ../contract/out/debug/*-abi.json -o ./src/contracts

About

Farm ๐Ÿ… on the Fuel network.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 83.2%
  • Sway 10.0%
  • Rust 4.1%
  • Other 2.7%