Skip to content

Commit

Permalink
Remove README sections with dead URLs
Browse files Browse the repository at this point in the history
these sections are orioginally from the upstream substrate-node-template
and don't seem to be relevant to Creditcoin!
  • Loading branch information
atodorov committed Nov 22, 2024
1 parent b23e2e9 commit ff995ed
Showing 1 changed file with 0 additions and 121 deletions.
121 changes: 0 additions & 121 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,6 @@

A Creditcoin3 node with the Ethereum RPC support, ready for deploying smart contracts.

## Generation & Upstream

This project was originally forked from the Frontier template. The template is maintained in the
[Frontier](https://github.com/paritytech/frontier/tree/master/template) project repository.

A ready-to-use template generated this way is hosted for each Frontier release on the
[substrate-developer-hub/frontier-node-template](https://github.com/substrate-developer-hub/frontier-node-template)
repository.

This template was originally forked from the
[Substrate Node Template](https://github.com/substrate-developer-hub/substrate-node-template). You
can find more information on features on this template there, and more detailed usage on the
[Substrate Developer Hub Tutorials](https://docs.substrate.io/tutorials/v3/) that use this heavily.

## Dev environment setup

To install tools & binaries used during development execute:
Expand Down Expand Up @@ -74,110 +60,3 @@ Running (takes 1 min to rebuild binaries):
```bash
docker run -t creditcoin3-node-dev
```

## Genesis Configuration

The development [chain spec](node/src/chain_spec.rs) included with this project defines a genesis
block that has been pre-configured with an EVM account for
[Alice](https://docs.substrate.io/v3/tools/subkey#well-known-keys). When
[a development chain is started](https://github.com/substrate-developer-hub/substrate-node-template#run),
Alice's EVM account will be funded with a large amount of Ether. The
[Polkadot UI](https://polkadot.js.org/apps/#?rpc=ws://127.0.0.1:9944) can be used to see the details
of Alice's EVM account. In order to view an EVM account, use the `Developer` tab of the Polkadot UI
`Settings` app to define the EVM `Account` type as below. It is also necessary to define the
`Address` and `LookupSource` to send transaction, and `Transaction` and `Signature` to be able to
inspect blocks:

```json
{
"Address": "MultiAddress",
"LookupSource": "MultiAddress",
"Account": {
"nonce": "U256",
"balance": "U256"
},
"Transaction": {
"nonce": "U256",
"action": "String",
"gas_price": "u64",
"gas_limit": "u64",
"value": "U256",
"input": "Vec<u8>",
"signature": "Signature"
},
"Signature": {
"v": "u64",
"r": "H256",
"s": "H256"
}
}
```

Use the `Developer` app's `RPC calls` tab to query `eth > getBalance(address, number)` with Alice's
EVM account ID (`0xd43593c715fdd31c61141abd04a99fd6822c8558`); the value that is returned should be:

```text
x: eth.getBalance
340,282,366,920,938,463,463,374,607,431,768,211,455
```

> Further reading:
> [EVM accounts](https://github.com/danforbes/danforbes/blob/master/writings/eth-dev.md#Accounts)
Alice's EVM account ID was calculated using a utility script.

## Example 1: Deploy basic contract using Remix & Metamask

### Adding local network to Metamask

Creditcoin3 is compatible with most tooling from the Ethereum ecosystem, including browser wallets like Metamask. To connect to your local dev node, add it as a new network:

```text
Network name: Creditcoin3 Local
New RPC URL: http://127.0.0.1:9944
Chain ID: 42
Currency symbol: CTC
Block explorer URL: <empty>
```

### EVM accounts

To fund an account, simply transfer from one of the dev accounts. Import the Alith account to Metamask and you should see it funded with 1M CTC.

Alith (SUDO) keys:

```text
Address: 0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac
Private key: 0x5fb92d6e98884f76de468fa3f6278f8807c48bebc13595d45af5bdc4da702133
```

### Deploying contracts with Remix

We will deploy a simple Counter contract:

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
contract TestCounter {
int private count = 0;
function incrementCounter() public {
count += 1;
}
function decrementCounter() public {
count -= 1;
}
function getCount() public view returns (int) {
return count;
}
}
```

1. Open the [Remix IDE](https://remix.ethereum.org/). In the Remix IDE, click on the Solidity tab and create a new file called Counter.sol. Paste the Counter contract in the file.

2. In the Remix IDE, click on the Deploy & Run tab. In the Environment dropdown, select Injected Web3. This will prompt you to connect to Metamask.

3. Click on Deploy and Metamask should prompt you to sign the transaction.

4. Once deployed, you can interact with the contract through the Deployed Contracts dropdown menu. Try sending transactions to increase and decrease the counter.

0 comments on commit ff995ed

Please sign in to comment.