question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't access abstract contract object when requiring MyContract.sol.js

See original GitHub issue

Hi. I am trying to use a custom build process but I am having difficulty accessing the contract object after the load in order to call new.

This is what I have working so far:

const Pudding = require('ether-pudding')
const MyContract = require('../environments/development/contracts/MyContract.sol.js')
MyContract.load(Pudding)

When I try to run MyContract.new({ from: web3.eth.accounts[0] }) I get:

TypeError: Cannot read property 'apply' of undefined
    at Function.Contract.new (../environments/development/contracts/MyContract.sol.js:38:32)

Which is this code:

  Contract.new = function() {
    if (Contract.Pudding == null) {
      throw new Error("MyContract error: Please call load() first before calling new().");
    }

    // Error occurs here, stating that 'new' is undefined
    return Contract.Pudding.new.apply(Contract, arguments);
  };

What am I missing?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
raineorshinecommented, Jun 6, 2016

Problem solved when I switched to ether-pudding v2.x. Thanks!

0reactions
tcoultercommented, Jun 6, 2016

👏

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there any way to access abstract contract in web3?
I want to use interface of ERC20 in my dapp and users will be able to enter the valid addresses of existing ERC20...
Read more >
Solidity - Abstract Contract - GeeksforGeeks
An instance of an abstract cannot be created. Abstract contracts are used as base contracts so that the child contract can inherit and ......
Read more >
web3.js contract object re-design · Issue #68 · ethereum/EIPs
Abstract. This proposal is a move to make it a more future proof javascript representation of a ethereum smart contract.
Read more >
Solidity: How to know when to use Abstract Contracts vs ...
Contracts are identified as abstract contracts when at least one of their functions lacks an implementation. As a result, they cannot be compiled....
Read more >
Accessing events from interface contract - Event doesn't exist ...
Yes you have to declare the event inside your contract for accessing it externally. As an example, consider the ERC20 smart-contract's solidity code...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found