Griptape.js
  • What is Griptape.js?
  • 🛹Getting Started
  • 🚀Bootstrapping Your App
  • 🗞️Interacting with Contracts
    • Contract Definitions
      • More on Definitions
    • Creating Contract Clients
    • Built-In Definitions
    • Extending Contract Definitions
    • Contract Registry
    • Instantiating Contracts
  • 🔑Using Viewing Keys and Permits
    • Using the viewing key manager
    • Using Keplr with Griptape
    • Managing Permits
  • 🕢Handling Events
  • ⚒️Using Utilities
  • 🔀API Reference
    • Bootstrap
    • Contracts
    • Viewing Keys
    • Permits
    • Events
    • Utilities
  • 🐝Tricks Tutorials
    • React Tutorials
      • Hello, Griptape
      • Hello, Contracts
      • Hello, Events
      • Hello, Viewing Keys
      • Hello, Permits
      • Hello, Transactions
      • Hello, Mint
    • Vue Tutorials
      • Hello, Griptape
      • Hello, Contracts
      • Hello, Events
      • Hello, Viewing Keys
      • Hello, Permits
      • Hello, Transactions
      • Hello, Mint
  • 💾Hackathon
    • Welcome Packet
    • Getting Set Up
    • Glossary
Powered by GitBook
On this page
  1. Interacting with Contracts

Creating Contract Clients

Once we have a contract definition, we can create a client contract. Creating a client contract in Griptape is simply using the createContractClient function and pass in the following data:

import {
  ContractDefinition,
  ContractMessageResponse,
  createContractClient
} from '@stakeordie/griptape.js';

interface SecretCounter {
  getCount(): Promise<{ count: number }>;
  increment(): Promise<ContractMessageResponse>;
}

const secretCounterDef: ContractDefinition = {
  queries: { ... }
  messages: { ... }
};

const secretCounter = createContractClient<SecretCounter>({
  at: 'secret1w97ynhe099cs5p433dvlaqhsxrszudz2n3f56h',
  definition: secretCounterDef
});

Now you can do:

const queryRes = await secretCounter.getCount();
// or
const messageRes = await secretCounter.increment();

Now you are able to interact with contracts!

PreviousMore on DefinitionsNextBuilt-In Definitions

Last updated 3 years ago

🗞️