Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Commit

Permalink
Deploy how it works page (#871)
Browse files Browse the repository at this point in the history
split overview page to how it works
  • Loading branch information
ciaranightingale authored Sep 12, 2023
1 parent 8f215ca commit df13d0b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 41 deletions.
41 changes: 0 additions & 41 deletions docs/onboarding/16 Deploy/0 Overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,44 +28,3 @@ Benefits of using Deploy:
- Automatically verifies your contract on [Sourcify](https://sourcify.dev/).
- Automatically adds your contract to the [dashboard](/dashboard) - this step is [gasless](/glossary/gasless-transactions)! This means you can easily manage and interact with your contract.
- No need to copy your contract ABI when integrating your smart contract into a web3 app.

## How Does it Work?

By using Deploy, your contract metadata is automatically uploaded to IPFS and verified
making your contract usable in any web3 app without having to copy your contract ABI.

This works by:

1. Using the default behavior of solc (the solidity compiler) - appending the encoded contract metadata to the contract bytecode.
2. Uploading the contracts metadata to IPFS

### Encoding & Extracting the Contract Metadata

By default, when compiling any solidity contract, the solc compiler:

1. Computes the IPFS hash of the contract metadata JSON artifact
(containing information including the contract name, ABI, source code, comments and compiler settings).
2. Encodes the computed IPFS hash using CBOR encoding
3. Appends the encoded bytes at the end of the compiled bytecode

This means that from any deployed contract, you can:

1. Get the contract bytecode using the standard RPC call `eth_getCode`.
2. Decode the data at the end of the bytecode using a CBOR decoder.
3. Extract the IPFS hash from the decoded data.
4. Download the original contract metadata which contains source code, ABI, etc.

Since **IPFS hashes are immutable**, the encoded contract metadata is guaranteed to be correct and unmodified.
This means that all contracts are auto-verifiable by design and without needing any third party! However, **the compiler only computes the IPFS hash and encodes it, it does not upload anything to IPFS**!

### Uploading Contract Metadata to IPFS

By using Deploy:

1. Your contract metadata is **automatically uploaded to IPFS** meaning that we can make use of solc's default behavior to unlock our [SDKs](/sdk).
2. Your contract is **automatically verified** on [Sourcify](https://sourcify.dev/).

This makes it easy to build web3 apps, using our [SDKs](/sdk), without having to copy or update the contract ABI. Instead, the ABI is retrieved from the contract metadata uploaded to IPFS!
This acts as a **source of truth** and thus is always up to date.

For more information on how contracts are automatically verified using Deploy, visit the ["Self-verifiable contracts using solc and IPFS"](https://mirror.xyz/joenrv.eth/DdbK6GR-CkeYxHoU8sKl0AFYbGeQwZcvCM5Qvzipr0g) blog post.
46 changes: 46 additions & 0 deletions docs/onboarding/16 Deploy/1 How it Works.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
slug: /deploy/how-it-works
title: How it Works
hide_title: true
---

# How it Works

By using Deploy, your contract metadata is automatically uploaded to IPFS and verified
making your contract usable in any web3 app without having to copy your contract ABI.

This works by:

1. Using the default behavior of solc (the solidity compiler) - appending the encoded contract metadata to the contract bytecode.
2. Uploading the contracts metadata to IPFS

## Encoding & Extracting the Contract Metadata

By default, when compiling any solidity contract, the solc compiler:

1. Computes the IPFS hash of the contract metadata JSON artifact
(containing information including the contract name, ABI, source code, comments and compiler settings).
2. Encodes the computed IPFS hash using CBOR encoding
3. Appends the encoded bytes at the end of the compiled bytecode

This means that from any deployed contract, you can:

1. Get the contract bytecode using the standard RPC call `eth_getCode`.
2. Decode the data at the end of the bytecode using a CBOR decoder.
3. Extract the IPFS hash from the decoded data.
4. Download the original contract metadata which contains source code, ABI, etc.

Since **IPFS hashes are immutable**, the encoded contract metadata is guaranteed to be correct and unmodified.
This means that all contracts are auto-verifiable by design and without needing any third party! However, **the compiler only computes the IPFS hash and encodes it, it does not upload anything to IPFS**!

## Uploading Contract Metadata to IPFS

By using Deploy:

1. Your contract metadata is **automatically uploaded to IPFS** meaning that we can make use of solc's default behavior to unlock our [SDKs](/sdk).
2. Your contract is **automatically verified** on [Sourcify](https://sourcify.dev/).

This makes it easy to build web3 apps, using our [SDKs](/sdk), without having to copy or update the contract ABI. Instead, the ABI is retrieved from the contract metadata uploaded to IPFS!
This acts as a **source of truth** and thus is always up to date.

For more information on how contracts are automatically verified using Deploy, visit the ["Self-verifiable contracts using solc and IPFS"](https://mirror.xyz/joenrv.eth/DdbK6GR-CkeYxHoU8sKl0AFYbGeQwZcvCM5Qvzipr0g) blog post.

1 comment on commit df13d0b

@vercel
Copy link

@vercel vercel bot commented on df13d0b Sep 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.