Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling compile(..) leads to "TypeError: UTIL.inherits is not a function" #1

Open
jsdw opened this issue Nov 14, 2024 · 1 comment
Open

Comments

@jsdw
Copy link

jsdw commented Nov 14, 2024

Hello!

Having a go playing with smart contracts and making a UI, I ran into the titled error. My code:

import { compile } from '@parity/revive'

const CONTRACT_NAME = "Message"
const CONTRACT = `
  // SPDX-License-Identifier: GPL-3.0
  pragma solidity >=0.7.0 <0.9.0;

  contract Message {

      address payable public owner;
      string public message;

      event MessageChanged(string message);

      constructor() {
          owner = payable(msg.sender);
      }

      function setMessage(string calldata m) external payable {
          require(msg.value >= 1 ether, "1 ETH required");
          message = m;
          emit MessageChanged(m);
      }

      function withdraw(uint amount) external {
          require(msg.sender == owner, "Only the contract owner can call this");
          (bool success, ) = msg.sender.call{ value: amount }("");
          require(success, "Transfer failed");
      }
  }
`

compile({
      [CONTRACT_NAME]: {
        content: CONTRACT,
      },
})

Running this leads to the titled error:

Screenshot 2024-11-14 at 16 53 35

Commenting out the compile line makes the error go away.

This could well be something totally unrelated since I'm new to smart contracts, but I wanted to raise it just incase :)

My dependencies (Using SolidJS's default TS template with Vite to play around here):

  "devDependencies": {
    "solid-devtools": "^0.29.2",
    "typescript": "^5.3.3",
    "vite": "^5.0.11",
    "vite-plugin-solid": "^2.8.2"
  },
  "dependencies": {
    "@parity/revive": "^0.0.5",
    "ethers": "^6.13.4",
    "solid-js": "^1.8.11"
  }
@jsdw
Copy link
Author

jsdw commented Nov 14, 2024

Ah perhaps I can answer my own bug; is this not supposed to work client side?

I see in the tutorial (https://contracts.polkadot.io/getting-started-with-ethers.js): "Using Node.js, Deno, or Bun, you can compile your contract to Polkavm bytecode using the @parity/revive package." which hints that this step isn't browser friendly :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant