apibara/starknet-react

Add Universal Deployer Contract

Opened this issue · 0 comments

fracek commented

We need to add the Universal Deployer Contract (UDC) contract hook to get a Contract already configured to interact with the UDC. The hook should be called useUniversalDeployerContract.

How it works

The hook wraps useContract and configures it for use with the UDC. It accepts the following arguments:

  • address: optional. Overrides the UDC address.
  • provider: optional. Overrides the provider.

Notice you will have to manually create the contract ABI since the version online is in the old ABI format.

Testing plan

We add a section under "Introduction" called "Deploying Contracts" that explains how to use the hook together with useSendTransaction.

We add a documentation page specific for the hook that shows the hook api.

We will add a demo that shows how to deploy a contract by combining useUniversalDeployerContract and useSendTransaction. We use this ERC20 class hash on sepolia for the test.

The constructor of the contract has the following abi, the demo will hard code all values and set all ContractAddress values to the user's wallet address. The token name is Starknet React Demo and symbol is SRD, decimals is 18. Initial supply should be something large like with 18 or more zeros. Upgrade delay can be any value that works.

  {
    "name": "constructor",
    "type": "constructor",
    "inputs": [
      {
        "name": "name",
        "type": "core::felt252"
      },
      {
        "name": "symbol",
        "type": "core::felt252"
      },
      {
        "name": "decimals",
        "type": "core::integer::u8"
      },
      {
        "name": "initial_supply",
        "type": "core::integer::u256"
      },
      {
        "name": "recipient",
        "type": "core::starknet::contract_address::ContractAddress"
      },
      {
        "name": "permitted_minter",
        "type": "core::starknet::contract_address::ContractAddress"
      },
      {
        "name": "provisional_governance_admin",
        "type": "core::starknet::contract_address::ContractAddress"
      },
      {
        "name": "upgrade_delay",
        "type": "core::integer::u64"
      }
    ]
  },