Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions interwovenkit/features/autosign/usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,60 @@ When `autoSign.enable()` is called:
The method returns a Promise that resolves when autosign is successfully enabled
or rejects if the user cancels or an error occurs.

## Sending transactions with autosign

Once autosign is enabled, you can send transactions without user confirmation
using `submitTxBlock`. This method signs and broadcasts transactions directly
using the ghost wallet.

```tsx
import { calculateFee, GasPrice } from '@cosmjs/stargate'
import { MsgSend } from 'cosmjs-types/cosmos/bank/v1beta1/tx'
import { useMutation } from '@tanstack/react-query'
import { useInterwovenKit } from '@initia/interwovenkit-react'

function SendWithAutosign() {
const { initiaAddress, submitTxBlock, estimateGas } = useInterwovenKit()

const { mutate, isPending } = useMutation({
mutationFn: async () => {
const messages = [
{
typeUrl: '/cosmos.bank.v1beta1.MsgSend',
value: MsgSend.fromPartial({
fromAddress: initiaAddress,
toAddress: 'init1...', // recipient address
amount: [{ amount: '1000000', denom: 'uinit' }],
}),
},
]

// Estimate gas and calculate fee
const gasEstimate = await estimateGas({ messages })
const fee = calculateFee(
Math.ceil(gasEstimate * 1.4),
GasPrice.fromString('0.015uinit'),
)

// Submit transaction directly (no modal)
const { transactionHash } = await submitTxBlock({ messages, fee })
return transactionHash
},
})

return (
<button onClick={() => mutate()} disabled={isPending}>
Send
</button>
)
}
```

<Tip>
Use `submitTxBlock` for seamless transactions with autosign. For transactions
requiring user confirmation, use `requestTxBlock` instead.
</Tip>

## Disabling Autosign

Users can disable autosign at any time. This revokes all grants for the selected
Expand Down
Loading