feat request: Add script action #2406
Replies: 2 comments
-
ts-playground
|
Beta Was this translation helpful? Give feedback.
-
So this chagnes my opinion on how this would be implemented: https://github.com/wevm/viem/pull/2405/files#diff-5c348edc08dfc2e4da2ade593c248ed35d97338797d68790f4d863ac1b2b7eceR38 I think since you overloaded this functionality into call then what I'm proposing should also be overloaded. That would mean just adding code as an option to call and then also adding code as an option to readContract the action I proposed then would just be readContract({code, abi, args, functionData}) rather than script({code, abi, args, functionData}). In which case I would go ahead and do the breaking change immediately to remove tevmScript from tevm for a similar pattern |
Beta Was this translation helpful? Give feedback.
-
Problem
Sometimes users want to run contract bytecode. This is possible to do both with tevm and viem, but >90% of users will not know you can do this with viem. Most users will go through the effort of spinning up a backend without even realizing they can do it with viem.
Solution
Add
viem.script
or alternativelyviem.callWithBytecode
orviem.runBytecode
action for specifically this (I prefer viem.script)How does it work
To run arbitrary bytecode you simply need to do following:
Beta Was this translation helpful? Give feedback.
All reactions