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.

Support for truffle v5 - use contract at specific address

See original GitHub issue

The generated types don’t have function for use contract at a specific address: https://www.trufflesuite.com/docs/truffle/getting-started/interacting-with-your-contracts#use-a-contract-at-a-specific-address.

import BN from 'bn.js'
import { ERC20TokenContract } from '../src/types/ERC20Token'

const ERC20Token: ERC20TokenContract = artifacts.require('ERC20Token')

contract('ERC20Token', (accounts: string[]) => {
  it('test', async () => {
    let token = await ERC20Token.new('tst', 'test', new BN(18))
    await token.supply(accounts[0], accounts[1], new BN(10).pow(new BN(18)))
    console.log(await token.totalSupply())
    // typechain does not support this
    // let token2  = await ERC20Token.at(token.address);
  })
})

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ducquangkstncommented, Mar 16, 2021

After a while, I figure out I must include typechain outDir in tsconfig.json

I add a PR to help others with the same issue https://github.com/ethereum-ts/TypeChain/pull/352

1reaction
quezakcommented, Feb 19, 2021

@ducquangkstn would you like to prepare & test a PR? We’re more versed in using ethers here 😃 This is the relevant file, it should be a simple matter of adding a static method declaration. You could even add some of the other contract static methods.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Interact with your contracts - Truffle Suite
Use a contract at a specific address¶. If you already have an address for a contract, you can create a new abstraction to...
Read more >
Add feature to deploy a contract at a specific address #5141
I am developing a contract, which can be easily developed using Truffle Suite. But I am having a problem when I am writing...
Read more >
Interacting with Your Contracts - Truffle Suite
Every time you call a function against a contract on the Tezos blockchain, a transaction is recorded. Each transaction will cost you XTZ,...
Read more >
How to write, test and deploy Ethereum smart contracts using ...
This article will look at writing, testing and deploying a smart contract using the Solidity programming language and Truffle.
Read more >
How does a Truffle migration know the address of a contract ...
Managed to get an answer from the developer of the project. In case anyone else finds themselves here: Contract addresses are deterministic ...
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