-
Does I don't find any documentation on this! I tried the following which fails contractInstance[''].apply(contractInstance); //giving it a blank string as the function name |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 4 replies
-
This is a good idea to add to the Interface object, for completion. However, it is not strictly needed. Calling the default function can be achieved simply by sending a transaction to the contraxct: var tx = {
to: contractAddress,
value: ethers.utils.parseEther("1.0")
};
wallet.sendTransaction(tx).then(function(tx) {
console.log(tx);
}); You bring up an interesting thing I had not considered though... Can the default function |
Beta Was this translation helpful? Give feedback.
-
Whats the status on this? |
Beta Was this translation helpful? Give feedback.
-
@GregTheGreek Still has not been added. I'm still mulling it over, especially insight of the new Solidity changes. There almost either needs to be zero functions to do this, or two separate options (of which, for any given situation, only one would be valid, I think?)... Both seem correct, but zero seems cleaner. :p I still need to catch up on the "received" Solidity feature. |
Beta Was this translation helpful? Give feedback.
-
For now, I think the best way to perform these operations is to rely on manually sending to the contract address. I may consider adding a function for But please re-open if you feel this is something that is important to be part of a Contract object. Thanks! :) |
Beta Was this translation helpful? Give feedback.
-
So how can we get data returned from fallback() function of proxy contract? |
Beta Was this translation helpful? Give feedback.
-
Hey @psytron, if your fallback function returns a value and you directly calling the contract using const result = await provider.call({
to: contractAddress,
data: '0x1234..' // encoded data
}) If your proxy contract is a minimal proxy contract like EIP-1167, then you can simply pass the proxy address to the Contract. const myContract = new ethers.Contract(proxyAddr, implementationAbi, provider); |
Beta Was this translation helpful? Give feedback.
-
Marvelous. Thank You @zemse |
Beta Was this translation helpful? Give feedback.
-
Welcome :) |
Beta Was this translation helpful? Give feedback.
Hey @psytron, if your fallback function returns a value and you directly calling the contract using
sendTransaction(tx)
, then you can't get the return value trivial since it's a transaction (though it could be extracted from an execution trace somehow). If you instead wanted to do a simple read call (to a maybe view or pure function), you can do following:If your proxy contract is a minimal proxy contract like EIP-1167, then you can simply pass the proxy address to the Contract.