I have a simple hello world contract, compiled with Vyper. I use Web3j CLI to make a Java wrapper class from the contract's abi and bin files. When I deploy it, I get a stack underflow error.

  • I know the Vyper contract works, because I successfully deployed it with Truffle.
  • I know my Web3j project is okay, because it can successfully deploy a Solidity hello world contract.

QUESTION: Why won't Web3j deploy a simple Vyper contract?

The Ganache Error: {"error":"stack underflow","program_counter":1,"return":"0x"}

Vyper compile commands:

vyper -f abi -o hello.abi hello.vy
vyper -f bytecode -o hello.bin hello.vy


  • Ganache CLI v6.12.2 (ganache-core: 2.13.2)
  • Web3j 4.9.6
  • Vyper 0.3.7

1 Answer 1


My Vyper contract caused a Ganache error, because the vyper compiler formats its bytecode output with a 0x prefix and a \n suffix.

web3j-cli takes that string as is and puts it into a contract Java wrapper class. When ganache-cli receives that binary string, it throws a "stack underflow" error.

After stripping off the unwanted chars, the contract deploys successfully.

As of Feb. 2022, Web3j doesn't officially support contracts compiled from Vyper. But you can make it work, as I explained.

When solcjs outputs a contract's binary, it does not add 0x or \n.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.