ethereum / solidity

Solidity, the Smart Contract Programming Language
https://soliditylang.org
GNU General Public License v3.0
23.14k stars 5.73k forks source link

Feature Request: Generate Language Specific Object Contract Mapper from ABI #14850

Closed James4Ever0 closed 1 month ago

James4Ever0 commented 7 months ago

Abstract

When compile Solidity contracts, also generate external callable language specific (Python, Rust, TypeScript, etc.) Object Contract Mapper code, similar to Object Document Mapper in MongoDB.

Users can create or retrieve a Solidity contract, interact with it using language specific methods, getting type hints and type validations inside IDE.

Motivation

EVM languages are typically without any OCM. They require users to figure out the boilerplate code and is highly error-prone, just like the early days in using SQL to interact with databases.

Solidity contracts are called in language specific clients (web3.py, web3.js), and it shall be pretty natural to generate language specific interfaces to interact with application code. This can greatly enhance the capability of Solidity and reduce development time, encouraging more Web2 developers using Solidity as their first Web3 smart contract language.

Specification

The OCM can be obtained in two ways. One is to generate the OCM by contract ABI, the other is to write the OCM by hand.

OCM shall be a normal class in application language, containing the constructor of the contract, method to retrieve existing contract by address, and all callable methods of the contract with type safe hints, also necessary method property like "pure" as docstring. In the future there might be some docstrings in Solidity, and OCM shall extract them as well as generated method docstring.

Backwards Compatibility

This proposal is available for all EVM compilers that generates ABI. The compatibility shall only be related to the specification of ABI. For docstring extraction, it would be related to the Solidity language specification.

github-actions[bot] commented 4 months ago

This issue has been marked as stale due to inactivity for the last 90 days. It will be automatically closed in 7 days.

James4Ever0 commented 4 months ago

This is not stale.

github-actions[bot] commented 1 month ago

This issue has been marked as stale due to inactivity for the last 90 days. It will be automatically closed in 7 days.

github-actions[bot] commented 1 month ago

Hi everyone! This issue has been automatically closed due to inactivity. If you think this issue is still relevant in the latest Solidity version and you have something to contribute, feel free to reopen. However, unless the issue is a concrete proposal that can be implemented, we recommend starting a language discussion on the forum instead.