Solidity Scale Codec, what AH was missing

Hello there,

I’m excited to share a project I’ve been working on: solidity-scale-codec. It is a library designed to bring native SCALE encoding and decoding capabilities directly to Solidity smart contracts.

The Problem
While Polkadot’s Substrate-based chains use the SCALE codec, the EVM natively speaks RLP and ABI. This mismatch creates a “language barrier” when a Smart Contracts wants to interact with Substrate pallets or complex precompiles.

The Solution: Unlocking XCM Precompiles
The primary motivation for this library is to unlock the full potential of the XCM Precompile.

By using solidity-scale-codec, Solidity developers can now construct and parse the complex types required by XCM natively within their contracts. This allows for:

  • Direct XCM Interaction: Encode XCM instructions (like Transact or Transfer) directly in Solidity to be passed to the precompile.
  • Broader Chain Interaction: Beyond XCM, it allows EVM contracts to interface more easily with any Substrate pallet that exposes a precompile interface requiring SCALE-encoded arguments.

Key Features

  • Native Solidity Implementation: No external dependencies or off-chain calls.
  • Comprehensive Support: Handles solidity native types, and provides means for encoding/decoding custom data structures.
  • Gas Efficient: Optimized to ensure that encoding/decoding on-chain remains viable for production use.

Links

I’d love to hear from other developers in the ecosystem. Are you working on XCM integrations where this could be useful? Are there specific Substrate types you’d like to see supported next?

Feel free to check out the repo, open an issue, or reach out here!

Best,
Lucas

2 Likes