Putting contract instance behind proxy? #2875
VladimirMikulic
started this conversation in
General
Replies: 1 comment 5 replies
-
You can override the getGasPrice in the provider. class CustomProvider extends StaticJsonRpcProvider {
async getGasPrice() {
return await getPriorityGasPrice()
}
}
const contract = new Contract(addr, abi, new CustomProvider('url'))
contract.fn(args) // if a gasPrice option is not provided, this should use your method |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Describe your Issue
Hi! I currently have a case where I override
gasPrice
on every function call to the contract.I have around 20 repetitions of
getPriorityGasPrice
across the codebase.To avoid repetition, I considered centralizing it all in one place by putting
contract
behindProxy
.https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy
However, I discovered that instances of
Contract
class are frozen so Proxy doesn't work.Is there a way for me to maybe prevent this locking or any other way of defining gasPrice in one place?
Thanks a lot!
This is an exception issue
Beta Was this translation helpful? Give feedback.
All reactions