biphan4 / evme-ics20 Goto Github PK
View Code? Open in Web Editor NEWa sandbox for testing out evmos' ics20 evm extension
a sandbox for testing out evmos' ics20 evm extension
# Evmos EVM Extensions - Simple Staker Example This is an example of how to create a smart contract that directly calls the `Staking` and `Distribution` precompiled contracts on Evmos chain - [Simple Staker](./contracts/SimpleStaker.sol) This smart contract allows the user to: - Stake tokens - Withdraw delegation rewards - Query current delegations - Query current delegations rewards The implementation is straightforward and is a good starting point for anyone who wants to create a smart contract that interacts with the Cosmos SDK. There are a couple of things to keep in mind when using the precompiled contracts: ## Approvals Before executing certain transactions on the precompiled contracts, the user interacting with the smart contract must first approve these. In case of staking transactions, should specify the amount allowed. The smart contract developer can choose to either separate the approval and execution of the precompiled contracts transactions or to combine them into a single transaction. We have provided convenient constants - `MSG_DELEGATE`, `MSG_UNDELEGATE`, `MSG_REDELEGATE`, `MSG_CANCEL_UNDELEGATION` - for easier use. This is done by calling the `approve` function and will create an authorization grant for the given Cosmos SDK message. The [Simple Staker](./contracts/SimpleStaker.sol) has the function `approveRequiredMethods()` to perform the necessary approvals. It approves the required methods for staking tokens (`MSG_DELEGATE`). ## Allowances The `Staking` precompile will check if the message sender has enough allowance for the given message type and will return an error if the transaction exceeds the allowance. Decreasing the allowance after a successful transaction is not required since we handle it internally. ## Return Structs The precompiled contracts provide a set of structs that map to Cosmos SDK message returns types. These structs can be used as return types for smart contract functions or can be used to add further logic to your smart contracts. Once a transaction is executed, the return values can be used to verify the transaction was successful or be as inputs for additional logic. ## Failed Transactions The precompiled contracts provide verbose error messages for failed transactions. If a transaction fails, the state will not be persisted and the transaction will be reverted.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.