> ## Documentation Index
> Fetch the complete documentation index at: https://docs.transmissions.wtf/llms.txt
> Use this file to discover all available pages before exploring further.

# updateChannelLogic

> Update the creator and minter rules for a deployed channel

<Tip>
  Check out the [sdk quickstart guide](/sdk/quickstart) for help setting up your client.
</Tip>

## Usage

<CodeGroup>
  ```typescript app.ts theme={null}
  import { uplinkClient } from './config'
  import { creatorLogic, minterLogic } from './args'
  import { DYNAMIC_LOGIC } from '@tx-kit/sdk/constants'

  const { event } = await uplinkClient.updateChannelLogic({ 
      channelAddress: '0x1234567890123456789012345678901234567890', 
      { 
          logicContract: DYNAMIC_LOGIC, 
          creatorLogic,
          minterLogic 
      }
  })
  ```

  ```typescript args.ts theme={null}
  const erc20BalanceOfData = encodeAbiParameters(
      [{ type: "address", name: "address" }],
      [zeroAddress] // zero address placeholder swapped for caller address at runtime
  ) 

  // give each creator 10 interaction credits if they hold 1 or more WETH tokens

  export const creatorLogic = [{
      target: baseSepoliaWETH,
      signature: '0x70a08231',
      data: erc20BalanceOfData,
      operator: LogicOperators.gt,
      literalOperand: BigInt(1),
      interactionPowerType: LogicInteractionPowerTypes.uniform,
      interactionPower: BigInt(10)
  }]

  // give each minter 10 interaction credits if they hold 1 or more WETH tokens

  export const minterLogic = [{
      target: baseSepoliaWETH,
      signature: '0x70a08231',
      data: erc20BalanceOfData,
      operator: LogicOperators.gt,
      literalOperand: BigInt(1),
      interactionPowerType: LogicInteractionPowerTypes.uniform,
      interactionPower: BigInt(10)
  }]
  ```

  ```typescript config.ts theme={null}
  import { TransmissionsClient } from '@tx-kit/sdk'
  import { CreatePublicClient, CreateWalletClient } from 'viem'
  import { base } from 'viem/chains'

  const publicClient = createPublicClient({
      chain: base,
      transport: http()
  })

  const walletClient = createWalletClient({
      account, // from local private key or browser wallet
      chain: base,
      transport: http()
  })

  export const { uplinkClient } = new TransmissionsClient({
      publicClient,
      walletClient,
      chain: base
  })
  ```
</CodeGroup>

## Returns

```typescript theme={null}
{ 
  event: Log 
}
```

## Parameters

### channelAddress

* **type**: `string`

The target channel address

```typescript theme={null}
const { event } = await uplinkClient.updateChannelLogic({
  channelAddress: '0x1234567890123456789012345678901234567890',
  ...
})
```

### logicContract

* **type**: `string`

The address of the logic contract to use. Use `DYNAMIC_LOGIC` for the default logic contract, or address zero to disable all logic. Disabling logic means that everyone has unlimited interaction credits.

```typescript theme={null}
const { event } = await uplinkClient.updateChannelLogic({
  { logicContract: DYNAMIC_LOGIC, ... },
  ...
})
```

### creatorLogic

* **type**: `DynamicLogicInputs[]`

An array of creator logic rules. For the `DYNAMIC_LOGIC` contract, each rule specifies a target contract, function signature, data, operator, literal operand, interaction power type, and interaction power. Logic rules can be created by hand, or with the `UniformInteractionPower` and `WeightedInteractionPower` utilities.

Weighted interaction power rules can be used to give more interaction credits to users who hold more tokens. Uniform interaction power rules give the same number of interaction credits to all users who meet the rule's conditions.

If a user meets multiple logic rules, the highest interaction power from all rules is applied.

```typescript theme={null}

const erc20BalanceOfData = encodeAbiParameters(
    [{ type: "address", name: "address" }],
    [zeroAddress] // zero address placeholder swapped for caller address at runtime
)

const creatorLogic = [{
    target: baseSepoliaWETH, // target contract to query for logic
    signature: '0x70a08231', // function signature to query for logic
    data: erc20BalanceOfData, // data to pass to the function
    operator: LogicOperators.gt, // operator to apply to the result
    literalOperand: BigInt(1), // operand to compare the result to
    interactionPowerType: LogicInteractionPowerTypes.uniform, // type of interaction power to apply
    interactionPower: BigInt(10) // interaction power to apply
}]

// with the `UniformInteractionPower` utility
const creatorLogic = [
    new UniformInteractionPower(BigInt(10))
        .ifResultOf(baseSepoliaWETH, '0x70a08231', erc20BalanceOfData)
        .gt(BigInt(1))
]

// with the `WeightedInteractionPower` utility
const creatorLogic = [
    new WeightedInteractionPower()
        .ifResultOf(baseSepoliaWETH, '0x70a08231', erc20BalanceOfData)
        .gt(BigInt(1))
]

const { event } = await uplinkClient.updateChannelLogic({
  { logicContract: DYNAMIC_LOGIC, creatorLogic, ... },
  ...
})

```

### minterLogic

* **type**: `DynamicLogicInputs[]`

An array of minter logic rules for the `DYNAMIC_LOGIC` contract. Logic rules can be created by hand, or with the `UniformInteractionPower` and `WeightedInteractionPower` utilities.

Weighted interaction power rules can be used to give more interaction credits to users who hold more tokens. Uniform interaction power rules give the same number of interaction credits to all users who meet the rule's conditions.

If a user meets multiple logic rules, the highest interaction power from all rules is applied.

```typescript theme={null}
const erc20BalanceOfData = encodeAbiParameters(
    [{ type: "address", name: "address" }],
    [zeroAddress] // zero address placeholder swapped for caller address at runtime
)

const minterLogic = [{
    target: baseSepoliaWETH, // target contract to query for logic
    signature: '0x70a08231', // function signature to query for logic
    data: erc20BalanceOfData, // data to pass to the function
    operator: LogicOperators.gt, // operator to apply to the result
    literalOperand: BigInt(1), // operand to compare the result to
    interactionPowerType: LogicInteractionPowerTypes.uniform, // type of interaction power to apply
    interactionPower: BigInt(10) // interaction power to apply
}]

// with the `UniformInteractionPower` utility
const minterLogic = [
    new UniformInteractionPower(BigInt(10))
        .ifResultOf(baseSepoliaWETH, '0x70a08231', erc20BalanceOfData)
        .gt(BigInt(1))
]

// with the `WeightedInteractionPower` utility
const minterLogic = [
    new WeightedInteractionPower()
        .ifResultOf(baseSepoliaWETH, '0x70a08231', erc20BalanceOfData)
        .gt(BigInt(1))
]

const { event } = await uplinkClient.updateChannelLogic({
  { logicContract: DYNAMIC_LOGIC, minterLogic, ... },
  ...
})

```

### transactionOverrides (optional)

* **type**: `TransactionOverrides`

```typescript theme={null}
type TransactionOverrides = {
  accessList?: AccessList
  gas?: bigint
  maxFeePerGas?: bigint
  maxPriorityFeePerGas?: bigint
  nonce?: number
  value?: bigint
}
```

Overrides for the transaction

```typescript theme={null}
const { event } = await uplinkClient.updateChannelLogic({
    ...
    transactionOverrides: {
        gas: 1000000n
    }
})
```

## Calldata

generate calldata for the transaction

```typescript theme={null}
const { address, data } = await uplinkClient.calldata.updateChannelLogic({...})
```

### Returns

```typescript theme={null}
{
    address: string, // address of the target contract
    data: string // calldata for the transaction
}
```

## Gas Estimation

Estimate gas for the transaction

```typescript theme={null}
const gas = await uplinkClient.estimateGas.updateChannelLogic({...})
```

### Returns

```typescript theme={null}
bigint // gas estimate in wei
```
