{"id":29057550,"url":"https://github.com/hyperweb-io/hyperweb-boilerplate","last_synced_at":"2025-06-27T06:05:54.224Z","repository":{"id":258987569,"uuid":"866368499","full_name":"hyperweb-io/hyperweb-boilerplate","owner":"hyperweb-io","description":null,"archived":false,"fork":false,"pushed_at":"2024-11-09T07:55:36.000Z","size":241,"stargazers_count":0,"open_issues_count":4,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-11-09T08:17:46.471Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hyperweb-io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-02T06:09:19.000Z","updated_at":"2024-11-09T07:55:39.000Z","dependencies_parsed_at":"2024-10-21T15:04:02.416Z","dependency_job_id":null,"html_url":"https://github.com/hyperweb-io/hyperweb-boilerplate","commit_stats":null,"previous_names":["hyperweb-io/hyperweb-boilerplate"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hyperweb-io/hyperweb-boilerplate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperweb-io%2Fhyperweb-boilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperweb-io%2Fhyperweb-boilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperweb-io%2Fhyperweb-boilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperweb-io%2Fhyperweb-boilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hyperweb-io","download_url":"https://codeload.github.com/hyperweb-io/hyperweb-boilerplate/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperweb-io%2Fhyperweb-boilerplate/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262202496,"owners_count":23274380,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-27T06:05:52.214Z","updated_at":"2025-06-27T06:05:54.212Z","avatar_url":"https://github.com/hyperweb-io.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hyperweb\n\n\u003cp align=\"center\" width=\"100%\"\u003e\n    \u003cimg height=\"90\" src=\"https://github.com/user-attachments/assets/f672f9b8-e59a-4f44-8f51-df3e8d2eaae5\" /\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\" width=\"100%\"\u003e\n  \u003ca href=\"https://github.com/hyperweb-io/hyperweb-boilerplate/actions/workflows/e2e-tests.yaml\"\u003e\n    \u003cimg height=\"20\" src=\"https://github.com/hyperweb-io/hyperweb-boilerplate/actions/workflows/e2e-tests.yaml/badge.svg\" /\u003e\n  \u003c/a\u003e\n  \u003cbr /\u003e\n   \u003ca href=\"https://github.com/hyperweb-io/hyperweb-boilerplate/blob/main/LICENSE\"\u003e\u003cimg height=\"20\" src=\"https://img.shields.io/badge/license-MIT-blue.svg\"\u003e\u003c/a\u003e\n   \u003ca href=\"https://github.com/cosmology-tech/starshipjs\"\u003e\u003cimg height=\"20\" src=\"https://img.shields.io/badge/CI-Starship-blue\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n# Hyperweb Boilerplate\n\nWelcome to **Hyperweb**, the blockchain for JavaScript smart contracts. Hyperweb enables developers to write decentralized applications (dApps) using TypeScript, designed for cross-chain compatibility and ease of development.\n\n## Table of Contents\n\n- [Quickstart](#quickstart)\n  - [Bundle Contracts](#bundle-contracts)\n- [Infrastructure Setup](#infrastructure-setup)\n  - [Option 1: Using Starship](#option-1-using-starship)\n    - [Enable Kubernetes in Docker Desktop](#enable-kubernetes-in-docker-desktop)\n    - [Install `kubectl` and `helm`](#install-kubectl-and-helm)\n    - [Start Starship](#start-starship)\n    - [Interact with the Chain](#interact-with-the-chain)\n  - [Option 2: Using Docker](#option-2-using-docker)\n    - [Run Hyperweb with Docker](#run-hyperweb-with-docker)\n    - [Interact with Chain](#interact-with-chain)\n- [Run Tests](#run-tests)\n- [Usage](#usage)\n  - [Creating JSD Client](#creating-jsd-client)\n  - [Deploying and Interacting with the Contract](#deploying-and-interacting-with-the-contract)\n  - [Instantiating a Contract](#instantiating-a-contract)\n  - [Interacting with the Contract](#interacting-with-the-contract)\n  - [Evaluating Functions on the Contract](#evaluating-functions-on-the-contract)\n  - [Reading Contract State](#reading-contract-state)\n- [Development](#development)\n\n## Installation\n\n1. Clone the repository:\n\n```bash\ngit clone https://github.com/hyperweb-io/hyperweb-boilerplate.git\n\nyarn\n```\n\n## Repository overview\n\n* `src/`: Contains source code for each contract, with each sub-directory as a separate contract.\n  * `simple-state`: A simple contract to demonstrate state transitions.\n  * `amm-contract`: An automated market maker contract using the Bank module.\n* `scripts/`: Holds the build script to create contract bundles.\n* `__tests__/`: Includes test cases to validate contract functionality.\n* `dist/`: Output folder for bundled contracts ready for deployment.\n\n## Quickstart\n\n### Bundle Contracts\n\n1. Clean previous builds:\n```bash\nyarn clean\n```\n2. Build contracts:\n```bash\nyarn build\n```\n\nThis bundles the contracts from src/** into dist/contracts/.\n\n## Infrastructure Setup\n\n### Option 1: Using Starship\n[Starship](https://github.com/cosmology-tech/starship) is a Kubernetes-based blockchain orchestrator. It sets up a local blockchain environment with full cross-chain compatibility.\n\n#### Enable Kubernetes in Docker Desktop\nDocker Desktop includes a standalone Kubernetes server and client, as well as Docker CLI integration that runs on your machine.\nTo enable Kubernetes in Docker Desktop:\n\n1. From the Docker Dashboard, select the Settings.\n2. Select Kubernetes from the left sidebar.\n3. Next to Enable Kubernetes, select the checkbox.\n4. Select Apply \u0026 Restart to save the settings and then click Install to confirm.\n\n#### Install `kubectl` and `helm`. \n```bash\nyarn starship install  ## and follow steps to install kubectl and helm\n```\n\n#### Start Starship\n```bash\nyarn starship start\n```\nSpins up a local blockchain using configs/local.yaml.\nWait for Starship to initialize.\n\nFor more details, refer to the [Starship Docs](https://docs.cosmology.zone/starship/).\n\n### Option 2: Using Docker\nAlternatively, Hyperweb can be run using Docker, which simplifies setup and enables you to interact with the blockchain without requiring Kubernetes.\n\n#### Run Hyperweb with Docker\nTo spin up the chain using Docker, the following scripts are available in the package.json:\n\n* Run Docker container:\n  ```bash\n  yarn docker\n  ```\n\n* Stop and remove the container:\n  ```bash\n  yarn docker:stop\n  ```\n\n### Interact with chain\n\nThis will set up the same chain environment that Starship provides, allowing you to interact with the chain using the same endpoints:\n* REST: http://localhost:1317\n* RPC: http://localhost:26657\n* Faucet: http://localhost:8000\n* Exposer: http://localhost:8081\n* Registry: http://localhost:8001\n\nOnce the chain is running, you can follow the same steps to interact with the chain and run tests as detailed below.\n\n## Run Tests\nOnce the setup it complete, you can run tests to validate the contract functionality.\nRun tests:\n```bash\nyarn test\n```\nThe test suite deploys the contracts, interacts with them, and validates state transitions. The tests are located in `__tests__/`.\n\n---\n\n## Usage\n\n### Creating JSD Client\n\nOnce the contract is bundled, you need to create a client using `hyperwebjs` to interact with the Hyperweb chain.\n\nExample setup to create a `hyperwebjs` client:\n\n```ts\nimport { getSigningJsdClient, jsd } from 'hyperwebjs';\n\nasync function setupClient() {\n  const wallet = await DirectSecp256k1HdWallet.fromMnemonic(\"your-mnemonic\");\n  const rpcEndpoint = \"your-rpc-endpoint\";\n\n  const signingClient = await getSigningJsdClient({\n    rpcEndpoint,\n    signer: wallet\n  });\n\n  return signingClient;\n}\n```\n\n### Deploying and Interacting with the Contract\n\nTo deploy and instantiate the contract on the Hyperweb blockchain, read the bundled contract file and use the `hyperwebjs` client to broadcast it to the chain.\n\nExample deployment process:\n\n```ts\nimport fs from 'fs';\nimport path from 'path';\n\nasync function deployContract(signingClient, address) {\n  const contractCode = fs.readFileSync(path.join(__dirname, '../dist/contracts/bundle1.js'), 'utf8');\n\n  const msg = jsd.jsd.MessageComposer.fromPartial.instantiate({\n    creator: address,\n    code: contractCode,\n  });\n\n  const fee = { amount: [{ denom: 'token', amount: '100000' }], gas: '550000' };\n\n  const result = await signingClient.signAndBroadcast(address, [msg], fee);\n  console.log('Contract deployed:', result);\n}\n```\n\n### Instantiating a Contract\n\nTo instantiate the contract, use the `instantiate` method of the `hyperwebjs` client. The contract index will be returned, which is used to interact with the contract.\n\n```ts\nconst contractCode = fs.readFileSync('dist/contracts/bundle1.js', 'utf8');\nconst result = await signingClient.signAndBroadcast(address, [\n  jsd.jsd.MessageComposer.fromPartial.instantiate({\n    creator: address,\n    code: contractCode,\n  })\n], fee);\n\nconst contractIndex = jsd.jsd.MsgInstantiateResponse.fromProtoMsg(result.msgResponses[0]).index;\nconsole.log('Contract instantiated with index:', contractIndex);\n```\n\n### Interacting with the Contract\n\nOnce the contract is instantiated, you can invoke functions like `inc`, `dec`, or `read` to interact with it.\n\nExample to increment a value:\n\n```ts\nconst msg = jsd.jsd.MessageComposer.fromPartial.eval({\n  creator: address,\n  index: contractIndex,\n  fnName: \"inc\",\n  arg: JSON.stringify({ x: 10 }),\n});\n\nconst result = await signingClient.signAndBroadcast(address, [msg], fee);\nconsole.log('Increment result:', result);\n```\n\n### Evaluating Functions on the Contract\n\nTo evaluate functions like `inc`, `dec`, or any other function within the contract, you can use the `eval` message type.\n\nExample to decrement a value:\n\n```ts\nconst msg = jsd.jsd.MessageComposer.fromPartial.eval({\n  creator: address,\n  index: contractIndex,\n  fnName: \"dec\",\n  arg: JSON.stringify({ x: 5 }),\n});\n\nconst result = await signingClient.signAndBroadcast(address, [msg], fee);\nconsole.log('Decrement result:', result);\n```\n\n### Reading Contract State\n\nYou can query the state of the contract by using the `read` function.\n\nExample to read the contract state:\n\n```ts\nconst state = await queryClient.jsd.jsd.localState({ index: contractIndex, key: 'value' });\nconsole.log('Contract state:', state);\n```\n\n---\n\n## Development\n\nFor local development, you can run the tests provided in the `__tests__/` folder to validate contract functionality using `starshipjs` to simulate chain interactions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperweb-io%2Fhyperweb-boilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhyperweb-io%2Fhyperweb-boilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperweb-io%2Fhyperweb-boilerplate/lists"}