Typink is a React hooks library for building dApps that interact with ink! and Solidity smart contracts on Polkadot blockchains. With Typink, you get a unified developer experience - the same hooks and APIs work seamlessly across ink! v5 (WASM), ink! v6 (PolkaVM), and Solidity contracts.
Create a New Project
Start by creating a new Typink project using the interactive CLI:
pnpmcreatetypink@latest
yarncreatetypink@latest
bunxcreatetypink@latest
npmcreatetypink@latest
npxcreate-typink@latest
The CLI will guide you through an interactive setup:
1. Enter Project Name
? Project name: my-typink-dapp
2. Select Contract Type
Choose the type of contracts you'll be working with:
? Select contract type:
β― Ink! v6 (PolkaVM, pallet-revive)
Ink! v6 using Sol ABI (PolkaVM, pallet-revive)
Solidity (PolkaVM, pallet-revive)
Ink! v5 (WASM, pallet-contracts)
Contract Types:
Ink! v6 - Latest ink! version on PolkaVM (pallet-revive)
Ink! v6 Sol ABI - ink! v6 with Solidity-style ABI
Solidity - Solidity smart contracts on PolkaVM
Ink! v5 - Legacy ink! on WASM (pallet-contracts)
3. Select Networks
Choose one or more networks for your dApp:
Available networks depend on your contract type:
pallet-contracts (Ink! v5): Pop Testnet, Aleph Zero Testnet, Aleph Zero, Astar
pallet-revive (Ink! v6/Solidity): Pop Testnet, Passet Hub
Start Development
Navigate to your project and start the development server:
You'll receive a contract address after successful deployment.
2. Generate TypeScript Bindings
The project includes a pre-configured typegen script (./scripts/typegen.ts) that generates type-safe bindings for all contracts in src/contracts/artifacts/.
First, place your contract metadata/ABI files in src/contracts/artifacts/, then run:
This script automatically processes all metadata/ABI files in src/contracts/artifacts/ and generates TypeScript bindings to src/contracts/types/. The generated TypeScript API (e.g., MyContractApi) will be available in src/contracts/types/my_contract/.
3. Register Contract Deployment
Add your contract to src/contracts/deployments.ts:
Unified Hooks - Works with All Contract Types
Typink's hooks provide a unified API that works identically across ink! v5, ink! v6, and Solidity contracts.
useContract - Initialize Contract Instance
Get a typed contract instance:
useContractQuery - Query Contract State
Read contract state with automatic type inference:
Ink! v6 Flipper Example:
Solidity Storage Example:
π‘ The hooks are identical! Only the contract type and method names change.
useContractTx - Send Transactions
Execute contract transactions with the same API:
Ink! v6 Flipper Example:
Solidity Storage Example:
π‘ Identical hook usage! The only difference is the contract type and arguments.
useWatchContractEvent - Listen to Events
Watch for contract events with type-safe event data:
Ink! v6 Example:
π‘ Works the same for Solidity contracts! Just use your Solidity contract's event names.
useDeployerTx - Deploy New Contracts
Deploy new contract instances:
Setup Transaction Toaster
Before using txToaster(), configure the global adapter in your app provider:
Supported toast libraries:
Sonner (recommended) - SonnerAdapter
React-Toastify - ReactToastifyAdapter
React-Hot-Toast - ReactHotToastAdapter
See the txToaster documentation for more details.
Complete Example
Here's a complete component showing query, transaction, and events:
π‘ This exact same pattern works for Solidity contracts! Just change the contract type and method names.
import { useContract } from 'typink';
import { MyContractApi } from '@/contracts/types/my_contract';
function MyComponent() {
const { contract } = useContract<MyContractApi>(ContractId.MY_CONTRACT);
// contract is now fully typed based on your contract ABI
}