createSignerClient
Factory that builds a client with every query action and every signing action.
Setup
import { createSignerClient, createTransport, testnet, PrivateKeySigner } from "@left-curve/sdk"
const signer = PrivateKeySigner.fromMnemonic(process.env.DANGO_MNEMONIC!)
const client = createSignerClient({
chain: testnet,
transport: createTransport(),
signer,
})createSignerClient returns SignerClient = Client<Signer, PublicActions & SignerActions>. It is a strict superset of createPublicClient: every method on the public client is also on the signer client.
Configuration
chain — Chain. Chain config. Use local, devnet, testnet, or mainnet from @left-curve/sdk.
transport — Transport. GraphQL transport from createTransport(url?, config?).
signer — Signer. Implementation of the Signer interface. Use PrivateKeySigner for server-side keys or createSessionSigner for session-key flows.
name — string, optional, default: "Signer Client". Free-form label.
type — string, optional, default: "dango". Type marker.
Methods
A signer client exposes every method on createPublicClient plus the following mutations.
App mutations
| Method | Description |
|---|---|
broadcastTxSync | Broadcast a signed tx via the indexer |
signAndBroadcastTx | Sign messages with the client signer and broadcast |
transfer | Send a record of Address -> Coins |
execute | Execute one or more contract messages |
instantiate | Instantiate a contract from a code hash |
migrate | Migrate a contract to a new code hash |
storeCode | Upload a Wasm code blob |
storeCodeAndInstantiate | Upload and instantiate in one tx |
Account Factory mutations
| Method | Description |
|---|---|
registerUser | Create a new user and first account |
registerAccount | Register an additional account |
updateKey | Insert or delete a key on the account |
updateUsername | Change the username |
createSession | Sign SigningSessionInfo and return session |
DEX mutations
| Method | Description |
|---|---|
batchUpdateOrders | Create and/or cancel multiple limit orders |
swapExactAmountIn | Instant swap with exact input |
swapExactAmountOut | Instant swap with exact output |
provideLiquidity | Add liquidity to a pair |
withdrawLiquidity | Withdraw liquidity from a pair |
Perps mutations
| Method | Description |
|---|---|
depositMargin | Deposit collateral into the perps account |
withdrawMargin | Withdraw collateral |
submitPerpsOrder | Submit a market or limit perps order |
cancelPerpsOrder | Cancel one or all perps orders |
submitConditionalOrder | Submit one trigger-based conditional order |
submitConditionalOrders | Submit a batch of conditional orders |
cancelConditionalOrder | Cancel conditional order(s) |
setReferral | Set a referrer/referee mapping |
setFeeShareRatio | Set the referrer fee share ratio |
vaultAddLiquidity | Deposit into the perps vault |
vaultRemoveLiquidity | Burn vault shares for a withdrawal |
End-to-end example
import { createSignerClient, createTransport, testnet, PrivateKeySigner } from "@left-curve/sdk"
import type { Address } from "@left-curve/sdk"
const signer = PrivateKeySigner.fromMnemonic(process.env.DANGO_MNEMONIC!)
const client = createSignerClient({
chain: testnet,
transport: createTransport(),
signer,
})
const sender: Address = "0x1234567890abcdef1234567890abcdef12345678"
// Move funds
const receipt = await client.transfer({
sender,
transfer: {
"0xabcdef1234567890abcdef1234567890abcdef12": { dango: "1000000" },
},
})
// Place a limit order
await client.batchUpdateOrders({
sender,
creates: [
{
baseDenom: "dango",
quoteDenom: "bridge/usdc",
amount: { bid: { quote: "10000000" } },
price: { limit: "0.5" },
timeInForce: "GTC",
},
],
})Notes
- The signer is held by reference. Mutating its key after client creation is undefined behavior — build a new client instead.
- Mutations call
simulateinternally to estimate gas. To skip simulation, passgasLimitexplicitly.
See also
- createPublicClient — when you only need queries
- Concepts: Transactions — the sign/broadcast loop
- Concepts: Signers & Authentication