Skip to content

BuenoToken uses AccessControl, not Ownable - TokenTransfer.tsx incorrectly calls owner() #1

Description

@schmidsi

Problem

The BuenoToken.sol contract uses OpenZeppelin's AccessControl instead of Ownable, but the frontend code in packages/nextjs/app/contract/components/TokenTransfer.tsx is incorrectly trying to call an owner() function that doesn't exist.

Current Code (Incorrect)

In TokenTransfer.tsx lines 48-60:

// Check if user is owner
const { data: owner } = useReadContract({
  address: CONTRACT_ADDRESS,
  abi: buenaTokenAbi.abi as any,
  functionName: "owner",
});

const isOwner =
  owner && address
    ? (owner as string).toLowerCase() === address.toLowerCase()
    : false;

Contract Implementation

BuenoToken.sol uses AccessControl with roles:

  • MINTER_ROLE - for minting tokens
  • DEFAULT_ADMIN_ROLE - for admin functions

There is no owner() function in the contract.

Solution

The code should check if the user has the MINTER_ROLE using hasRole(MINTER_ROLE, address) instead of checking ownership.

Affected Files

  • packages/nextjs/app/contract/components/TokenTransfer.tsx (lines 48-60)

References

  • Contract: contracts/BuenoToken.sol
  • Uses: AccessControl with MINTER_ROLE
  • Does NOT use: Ownable

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions