solc in nodejs leaves contracts undefined

islandBillyislandBilly Member Posts: 5
I am trying to generate contract source and programmatically compile and deploy it under nodejs. It ain't workin! I was advised to use this when the eth.compile.solidity would not create abi codes as of v0.4.10, but the nodejs version leaves my contracts undefined, possibly due to the formal verification bug that declares address type in state variables to be an error. Here is some of my nodejs code:

solc = require('solc'); var contractSrc = 'whatever - trust me, it compiles fine in MixIDE'; var contractCompiled = solc.compile(contractSrc, 1); var contractABI = contractCompiled.contracts[Item0_1_0].interface;
That last command results in an error message to the effect that the contract of that name is undefined, even though the solc.compile command run on the nodejs console puts out data for bytecode, interface, metadata, opcodes and a bunch more, including "formal", in which it shows the error "Type "address" not supported for state variable." which is bullshit. Still, the formal verification could be preventing the contract object from being defined, I suppose. Something must be doing it.

Anybody know why this isn't working? I've seen questions about the address type not supported for years, and I can't go through the clunky manual process of compiling many small contracts on Mist and getting the codes I need to deploy them.

Comments

  • islandBillyislandBilly Member Posts: 5
    UPDATE: I just figured this out :)
    The contract name reference in that last line of code must be a string, and it seems to be the contract name prefixed by a ':', so the line should read: var contractABI = contractCompiled.contracts[":Item0_1_0"].interface;
    Now, on with deployment! Hope this helps somebody.
Sign In or Register to comment.