Skip to content

useDeployContract

Hook for deploying a Sophia smart contract.

Import

typescript
import { useDeployContract } from '@growae/reactive-react'

Usage

tsx
import { useDeployContract } from '@growae/reactive-react'

function Deploy() {
  const { mutate: deploy, data, isPending } = useDeployContract()

  return (
    <div>
      <button
        onClick={() =>
          deploy({
            aci: contractAci,
            bytecode: compiledBytecode,
            args: ['initial_value'],
          })
        }
        disabled={isPending}
      >
        Deploy Contract
      </button>
      {data && <p>Deployed at: {data.address}</p>}
    </div>
  )
}

Return Type

See TanStack Query mutation docs for full return type.

data

See deployContract Return Type.

Parameters

See deployContract Parameters for all options.

Key parameters include ttl which defaults to 300 blocks.

Default TTL

All transactions default to a TTL of 300 blocks (~15 hours). This prevents stale transactions from lingering indefinitely. Override with ttl: 0 for no expiration.

mutation

See TanStack Query mutation docs for mutation options.

Action