To Read in Full and ask questions: https://forum.trondao.org/t/solide-solidity-database/23385

Inspiration

In the age of decentralization and blockchain technology, the aim is to promote transparency and openness in data, independent of any controlling entity. Without this, information would remain siloed and access would be restricted. The systems powering smart contracts for these blockchains face similar challenges with each blockchain having its own storage system for smart contracts, and accessing smart contract sources on one chain may not be accessible on another others, even if they share the same implementation and settings. When smart contracts are deployed on a network, they receive storage for their bytecode, which can be de-siloed and optimized through decentralized source code storage to provide more information for both verified and unverified smart contracts.

The objective of the Solidity Database is to establish an open-source storage layer dedicated to every smart contract. Ultimately, the project aims to become a public good alternative for accessing the source code of smart contracts, utilizing the extensive technology of TRON and BTTC/BTFS to construct a fully decentralized database infrastructure capable of securely storing comprehensive contract information (and de-siloed it). This should not only enhance accessibility and transparency within the developer community but also foster a more inclusive and decentralized ecosystem for smart contract development on all EVM-based blockchains.

The project's value stems from establishing a robust system for managing smart contract sources, irrespective of their verification status, thereby promoting future interoperability, stimulating innovation, and enhancing user engagement across decentralized networks.

  • 📦 Optimized Storage - De-siloing facilitates the distribution of smart contract source code storage across different chains. Currently, verifying the same smart contract on two different chains results in storing different metadata in the explorer service and may require separate storage if using different block explorers. Utilizing the Solidity Database enables efficient use of smart contract metadata storage, which can be managed across multiple chains, thereby reducing redundancy and resource consumption.
  • 🌍 Interoperability - Optimizing and de-siloing the contracts metadata means that the project can extend and cater to other EVM-based chains using the TRON network, promoting interoperability across diverse blockchain ecosystems.
  • Increased Stability and Decentralization - The project utilizes decentralized services such as BTFS, enhancing transparency and accessibility. Leveraging BTFS establishes data availability, ensures data accessibility, and scalability, and strengthens both the BTFS protocol and the Solidity Database service.
  • 🔍 Simple and Open Source Querying - In effect to Increased Stability and Decentralization, utilizing services such as TRON and BTTC provides a reliable platform for deconstructing smart contracts (both verified and unverified) in a simple and seamless manner, which can be integrated into IDEs or explorers.

What it does

1. Storing Smart Contracts on Solidity Database

  • To deploy and contribute to the Solidity DB Registry (on TRON Nile), load a smart contract onto Solidity IDE.
    • For instance, load an ERC1155 Token from GitHub.
  • Set the correct compiler version and compile the smart contract.
  • Add constructor parameters and deploy the contract.

    • You can select from Metamask or TronLink (the image showing TRONLINK) ide-compile
  • After signing the contract creation, there should be the contract address

    • Check the contract has been successfully deployed by calling one of its methods. ide-deployment
    • This means that the IDE has deployed the contract and stores its information and metadata in the Solidity DB. ide-calling

2. Using Solidity Database with Solide IDE

  • To utilize the loading contracts from the Solidity Database, you can use contract deployed in step 1 (ensure it's not verified) by visiting /address/{chainId}/{contractAddress} where:

    • chainId represents the chain on which the contract is deployed.
    • contractAddress is the address of the smart contract.
    • Example: Unverified Contract - ERC1155 ide-load
    • Notice the warning icon displayed on the sidebar, indicating that the contract is not verified. Additionally, it signifies that the source code was provided by Solide IDE, accompanied by a BTFS CID for reference. ide-warn
  • You can interact with the contract just as if it was verified, compile, change and deploy the contract.

3. Using the Solidity DB Explorer

  • An alternative method for accessing and viewing contracts stored on Solidity DB is through an explorer platform.
  • To search for a specific smart contract address:

    1. Navigate to the Explorer platform.
    2. Input the contractAddress and select the blockchain in the nav bar. explorer-search
  • Alternatively, you can directly search via URL using the format: {chainId}/{contractAddress}.

  • The result typically includes a table presenting information about the contract address, along with a code explorer for its source code is available on the selected blockchain.

explorer-result

How we built it

Smart Contract: SolidityDatabaseRegistry

The SolidityDatabaseRegistry, currently operational on the TRON Nile testnet, serves as a repository for smart contract information stored on-chain, functioning as an open-source database for contracts. To understand its functionality and application, refer to the project instructions or explore its workings.

Essentially, this registry acts as a reference point for smart contracts, offering insights and details on deployed contracts, regardless of their verification status. Information stored within the smart contract includes the bytecode hash and a BTFS file CID. Such data, typically generated by compilers, proves invaluable for developers and IDEs.

For instance, consider an unverified smart contract with the address TVPaonF8QAWHAi59vcz3a93mQdNSATjnLP. Without accessing the SolidityDatabaseRegistry, users remain unaware of the contract's specifics. However, by leveraging the SolidityDatabaseRegistry contract and the bytecode associated with TVPaonF8QAWHAi59vcz3a93mQdNSATjnLP, retrievable from the blockchain, one can hash this value (resulting in 0x33e89f56fbc5c341da070b79e70b972efa956825053e24dcb8ef6899a249ea50). Utilizing this hash in the find() method of the smart contract yields crucial data, including a BTFS CID and timestamp linked to the contract's deployment.

sc-find

Upon inspecting the CID, you'll find comprehensive details including the source code and metadata of the contract. This ensures transparency and authenticity, providing assurance regarding the legitimacy and integrity of the contract even if it is unverified.

sc-cid

If this isn't enough, note that you can compile this contract in an IDE, either loading in Solide or any other IDE and compare the bytecode matches the one with the contract address being checked (provided by the blockchain)

By storing smart contract metadata, Solidity DB facilitates support for all EVM-based chains, ensuring cross-chain interoperability. For instance, the example contract TVPaonF8QAWHAi59vcz3a93mQdNSATjnLP deployed on TRON Nile, and then replicated the deployment on Polygon Mumbai using the same contract source code. This demonstrates the versatility of Solidity DB, allowing seamless deployment across diverse blockchain ecosystems.

The ability to utilize decentralized storage enhances this advantage, extending beyond individual chains like TRON and BTTC to encompass the broader blockchain space. Notably, when comparing the contracts deployed on TRON Nile and Polygon Mumbai, we observe identical contract sources (with the same BTFS CID). This consistency is because both deployments share the same bytecode provided by the Polygon blockchain, and utilise the Solidity DB's role in promoting cross-chain consistency and interoperability.

sc-polygon

Explorer

homepage

The Explorer will allow users to explore and interact with the Solidity Database. The need for this will create a user-friendly interface to view various information about the smart contract related to the source code. Whether it is verified on a chain or contains an entry in the Solidity Database, the exploration will make it easy for users to understand what the contract is going on. The potential for this explorer is unlimited, as integration with another service such as security, code analyzation etc (though we won't be implementing it in the hackathon)

Just like a blockchain explorer, you can search for a contact address and select a chain, or simply pass the chainId and the contract address. Sample of Contract in Explorer. The UI will be as simple to cater for everyone and will contain visual information on whether a contract is verified on a chain or in the Solidity Database. Also, there will be information about the contract about metadata for the contract. While this information is available on the chain explorer, here we are extending it to be for the Soidity Database.

search

For the example provided, if the smart contract was verified, then the information from the blockchain would be shown, however, this isn't the case, hence this information will not be available anything. But there with the Solidity Database Explorer, we are able to fill in all contracts and help developers get information about the compilation and source code of the smart contract. Of course, we provided external service to the explorer and in the future others to help the user.

data

ide

Note: This explorer is for visualizing and providing data to users about verified and unverified smart contracts. Should you wish to interact, deploy, or develop with the smart contract, you can load it into the Solide IDE.

Challenges we ran into

During our project, we encountered several challenges such as familiarizing ourselves with TRON and utilizing tronweb, so we spent some time studying TRON's architecture, smart contracts, and developer tool on TRON to ensure our implementation was robust and aligned with our project goals. Despite these challenges, our team's dedication and collaborative effort enabled us to navigate these obstacles and implement innovative solutions that leveraged TRON effectively within our project.

Accomplishments that we're proud of

We a proud of the successfully integrating TRON and its ecosystem (BTTC and BTFS) with Solide IDE, streamlining the Solidity Database integration for smoother developer experiences and enhanced smart contract development. This integration not only facilitated efficient coding but also contributed to building a more robust ecosystem for developers working on TRON. Additionally, our active participation and interaction on the TRON forum fostered valuable discussions, sharing insights, and gaining feedback from the community. These accomplishments reflect our commitment to advancing blockchain technology and empowering developers within the TRON ecosystem.

What's next for Solide Solidity Database

Further, enhance our integration efforts by streamlining continuous integration processes. Enhance the functionality of Explorer to provide a more intuitive and comprehensive user experience. Additionally, expand our compatibility to encompass a broader array of EVM chains, facilitating seamless cross-chain interactions. Collaborate with other IDEs to foster interoperability and establish a robust library that simplifies data retrieval for developers and DApps alike.

Useful links

Built With

Share this project:

Updates