A toolbox for working with Pact smart contracts
npm create vite@latest hello-world-dapp -- --template react-swc-ts
npx pact-toolbox init
// 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,
},
});
},
}),
],
});
- to check your system
npx pact-toolbox doctor
- to install pact
npx pact-toolbox pact install 4.10
npm run dev
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