### Initialize Project Configuration Source: https://github.com/openzeppelin/starter-kit/blob/master/README.md Initializes the OpenZeppelin project configuration, guiding the user through setup prompts. ```javascript npx oz init ``` -------------------------------- ### Start React Development Server Source: https://github.com/openzeppelin/starter-kit/blob/master/README.md Navigates to the client directory and starts the React development server to run the application. ```javascript cd client npm run start ``` -------------------------------- ### Install OpenZeppelin Starter Kit Source: https://github.com/openzeppelin/starter-kit/blob/master/docs/modules/ROOT/pages/starter.adoc Installs the OpenZeppelin Starter Kit by unpacking the 'starter' kit into a new, empty directory. This command is used to quickly set up a new dapp project. ```console openzepplin unpack starter ``` -------------------------------- ### Install GSN Starter Kit Source: https://github.com/openzeppelin/starter-kit/blob/master/docs/modules/ROOT/pages/gsnkit.adoc Command to unpack and install the OpenZeppelin GSN Starter Kit into a new project directory. ```console $ openzeppelin unpack OpenZeppelin/starter-kit-gsn ``` -------------------------------- ### Installing a Starter Kit Source: https://github.com/openzeppelin/starter-kit/blob/master/docs/modules/ROOT/pages/create.adoc Commands to install a starter kit from a GitHub repository. The first command installs the default stable branch, while the second allows specifying a particular branch. ```bash npx openzeppelin unpack 'OpenZeppelin/starter-kit' ``` ```bash npx openzeppelin unpack 'yourGitHubHandle/yourRepoName#branch' ``` -------------------------------- ### Install Dependencies Source: https://github.com/openzeppelin/starter-kit/blob/master/README.md Installs Ganache CLI and Truffle globally, which are required for running the local blockchain and testing smart contracts. ```bash npm install -g truffle@5.0.41 ganache-cli@6.7.0 ``` -------------------------------- ### Install and Unpack OpenZeppelin Starter Kit Source: https://github.com/openzeppelin/starter-kit/blob/master/docs/modules/ROOT/pages/index.adoc Installs the OpenZeppelin CLI globally and then unpacks the default starter kit. This is the primary method for setting up a new project with the starter kit. ```console $ npm install --global @openzeppelin/cli $ npx oz unpack starter ``` -------------------------------- ### Unpack Tutorial Starter Kit Source: https://github.com/openzeppelin/starter-kit/blob/master/docs/modules/ROOT/pages/tutorial.adoc Installs the OpenZeppelin Tutorial Starter Kit into a new directory. This command is used to initialize the project structure for learning and development. ```console $ openzeppelin unpack tutorial ``` -------------------------------- ### Run Local Blockchain Source: https://github.com/openzeppelin/starter-kit/blob/master/README.md Starts a local Ganache blockchain instance with deterministic accounts for development. ```bash ganache-cli --deterministic ``` -------------------------------- ### GSN Recipient Contract Example Source: https://github.com/openzeppelin/starter-kit/blob/master/docs/modules/ROOT/pages/gsnkit.adoc A Solidity contract example demonstrating inheritance from GSNRecipient and implementing acceptRelayedCall to accept all relayed calls. ```solidity pragma solidity ^0.5.0; import "@openzeppelin/contracts-ethereum-package/contracts/GSN/GSNRecipient.sol"; import "@openzeppelin/upgrades/contracts/Initializable.sol"; contract Counter is Initializable, GSNRecipient { //it keeps a count to demonstrate stage changes uint private count; address private _owner; function initialize(uint num) public initializer { GSNRecipient.initialize(); _owner = _msgSender(); count = num; } // accept all requests function acceptRelayedCall( address, address, bytes calldata, uint256, uint256, uint256, uint256, bytes calldata, uint256 ) external view returns (uint256, bytes memory) { return _approveRelayedCall(); } ... ``` -------------------------------- ### Development Server Source: https://github.com/openzeppelin/starter-kit/blob/master/client/README.md Starts the development server for the React application. It opens the app in the browser and provides hot reloading for edits. Lint errors are displayed in the console. ```bash npm start ``` -------------------------------- ### Initialize Web3 with GSN Context Source: https://github.com/openzeppelin/starter-kit/blob/master/docs/modules/ROOT/pages/gsnkit.adoc Example of using OpenZeppelin Network JS to establish a Web3 connection with GSN enabled for development. ```javascript const context = useWeb3Network('http://127.0.0.1:8545', { gsn: { dev: true, }, }); ``` -------------------------------- ### Starter Kit Configuration File (`kit.json`) Source: https://github.com/openzeppelin/starter-kit/blob/master/docs/modules/ROOT/pages/create.adoc The `kit.json` file is a mandatory configuration file for OpenZeppelin Starter Kits. It defines the manifest version, a display message, files to be included, and post-unpack hooks. The `post-unpack` hook is used to run commands after a kit is unpacked, such as installing dependencies. ```json { "manifestVersion": "0.1.0", "message": "More at https://github.com/OpenZeppelin/starter-kit", "files": [ ".gitignore", "LICENSE", "client", "contracts", "migrations", "package.json", "solhint.json", "test", "truffle-config.js" ], "hooks": { "post-unpack": "npm install && cd client && npm install" } } ``` -------------------------------- ### Initialize Starter Project Source: https://github.com/openzeppelin/starter-kit/blob/master/README.md Unpacks the OpenZeppelin Starter Kit into the current directory to create a new project. ```javascript npx @openzeppelin/cli unpack starter ``` -------------------------------- ### Build for Production Source: https://github.com/openzeppelin/starter-kit/blob/master/README.md Creates a production build of the React application. The output is placed in the `client/build` folder. ```javascript // ensure you are inside the client directory when running this npm run build ``` -------------------------------- ### OpenZeppelin CLI - Interact with Contracts Source: https://github.com/openzeppelin/starter-kit/blob/master/README.md Provides commands for interacting with deployed smart contracts using the OpenZeppelin CLI. ```APIDOC OpenZeppelin CLI Commands: `npx oz transfer` Sends funds to a given address. `npx oz balance [address]` Queries the ETH balance of a specified account, also supports ERC20s. `npx oz send-tx` Sends a transaction to your contract and returns the events. `npx oz call` Executes a constant method and returns the value. Type `npx oz` to see a complete list of available commands. ``` -------------------------------- ### Build for Production Source: https://github.com/openzeppelin/starter-kit/blob/master/client/README.md Builds the React application for production deployment. It optimizes the build for performance, minifies the code, and includes content hashes in filenames. ```bash npm run build ``` -------------------------------- ### Run Truffle Tests Source: https://github.com/openzeppelin/starter-kit/blob/master/README.md Executes tests written for smart contracts using the Truffle framework. ```javascript // inside the development console. test // outside the development console.. truffle test ``` -------------------------------- ### Run Jest Tests Source: https://github.com/openzeppelin/starter-kit/blob/master/README.md Executes tests for React components using Jest. Ensure contracts are compiled before running. ```javascript // ensure you are inside the client directory when running this npm run test ``` -------------------------------- ### Run Tests Source: https://github.com/openzeppelin/starter-kit/blob/master/client/README.md Launches the test runner in an interactive watch mode. This script is used for running unit and integration tests during development. ```bash npm test ``` -------------------------------- ### Eject Configuration Source: https://github.com/openzeppelin/starter-kit/blob/master/client/README.md Ejects the Create React App configuration, providing full control over build tools like Webpack and Babel. This is a one-way operation and should be used with caution. ```bash npm run eject ``` -------------------------------- ### Check Recipient Funds and Deployment Status Source: https://github.com/openzeppelin/starter-kit/blob/master/docs/modules/ROOT/pages/gsnkit.adoc JavaScript function to check if a GSN relay hub is deployed for a recipient and retrieve the remaining funds. ```javascript const getDeploymentAndFunds = async () => { if (instance) { const isDeployed = await isRelayHubDeployedForRecipient(lib, _address); setIsDeployed(isDeployed); if (isDeployed) { const funds = await getRecipientFunds(lib, _address); setFunds(funds); } } }; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.