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

Proxy Contracts #136

Open
spacesudo opened this issue Aug 21, 2024 · 10 comments
Open

Proxy Contracts #136

spacesudo opened this issue Aug 21, 2024 · 10 comments

Comments

@spacesudo
Copy link

How do I interact with proxy contracts and use functions of write as proxy?

@MrNaif2018
Copy link
Collaborator

Shouldn't it work like any regular contract, like calling methods from ABI on proxied contract?

@spacesudo
Copy link
Author

Well unfortunately, it doesn't work.
For typescript, there's a trigger smart contract function that is used to call proxy functions but I don't think there's such a thing on tronpy.

@MrNaif2018
Copy link
Collaborator

Could you please point me to such a function in typescript version? If it's indeed required I can implement it

@spacesudo
Copy link
Author

const contractAddress = "TTfvyrAz86hbZk5iDpKD78pqLGgi8C7AAw";

export async function buyTRXPump(address, amountTRX) {
  try {
    const transaction = await tronWeb.transactionBuilder.triggerSmartContract(
      contractAddress,
      "purchaseToken(address,uint256)",
      {
        feeLimit: 1000 * 10 ** 6, 
        callValue: amountTRX * 10 ** 6, 
      },
      [
        { type: "address", value: address },
        { type: "uint256", value: "0" },
      ],
      tronWeb.defaultAddress.base58
    );

This is just a code snippet using tronweb

@MrNaif2018
Copy link
Collaborator

I don't see any proxy-specific code here

@spacesudo
Copy link
Author

If you look at the contract address, it's a proxy contract and purchaseToken(address,uint256) is a write as proxy function.

My only question here is, as you can see, tronweb has a triggerSmartContract function which can be used in cases like this, but I don't think tronpy has something like this.

If I try to get the contract functions with contract.functions it only lists the normal functions of the contract and not the proxy functions

@MrNaif2018
Copy link
Collaborator

So you get an error like
contract has no method named purchaseToken?

@spacesudo
Copy link
Author

Exactly

@MrNaif2018
Copy link
Collaborator

Well I find no references of proxy support in their API either
plus even found this issue:
tronprotocol/tronweb#356

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

2 participants