solidity icon indicating copy to clipboard operation
solidity copied to clipboard

Feature Request: Generate Language Specific Object Contract Mapper from ABI

Open James4Ever0 opened this issue 1 year ago • 2 comments

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.

James4Ever0 avatar Feb 13 '24 07:02 James4Ever0

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] avatar May 13 '24 12:05 github-actions[bot]

This is not stale.

James4Ever0 avatar May 14 '24 11:05 James4Ever0

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] avatar Aug 12 '24 12:08 github-actions[bot]