Skip to content

kadena-community/pact-toolbox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pact-toolbox

A toolbox for working with Pact smart contracts

Getting started

Step 1: Create a vite project (typescript is recommended)

npm create vite@latest hello-world-dapp -- --template react-swc-ts

Step 2: Initialize a Pact toolbox project

npx pact-toolbox init

Step 3: Update vite.config.ts

// NOTE: don't ovveride the existing file, just update the necessary parts.
// import pact vite plugin
import pactVitePlugin from '@pact-toolbox/unplugin/vite';

export default defineConfig({
  plugins: [
    // add pact vite plugin
    pactVitePlugin({
      onReady: async (client) => {
        const isDeployed = await client.isContractDeployed('free.hello-world');
        await client.deployContract('hello-world.pact', {
          prepareTx: {
            upgrade: isDeployed,
          },
        });
      },
    }),
  ],
});

Step 4: Make sure you have pact installed

  • to check your system
npx pact-toolbox doctor
  • to install pact
npx pact-toolbox pact install 4.10

Step 5: Start vite dev server.

npm run dev

Project structure

hello-world-dapp
├── pact // pact files
│   ├── hello-world.pact // pact smart contract
│   └── hello-world.repl // pact repl file
├── scripts
│   ├── deploy.dev.ts // deploy script
│   ├── deploy.prod.ts // deploy script
├── src
│   ├── api.ts // @kadena/client api calls
├── pact-toolbox.config.ts // pact toolbox config file

Next steps

About

A toolbox for working with Pact smart contracts

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages