Skip to content

Commit

Permalink
Prettify
Browse files Browse the repository at this point in the history
  • Loading branch information
atodorov committed Oct 11, 2023
1 parent de6ab12 commit 6d76d64
Show file tree
Hide file tree
Showing 15 changed files with 2,856 additions and 2,775 deletions.
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<describe what this PR is about and why we want it>

---

Practical tips for PR review & merge:

- [ ] All GitHub Actions report PASS
Expand Down
2 changes: 1 addition & 1 deletion .markdown-link-check.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
],
"retryOn429": true,
"retryCount": 5,
"aliveStatusCodes": [ 200, 203 ]
"aliveStatusCodes": [200, 203]
}
45 changes: 23 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,26 +74,26 @@ 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"
}
"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"
}
}
```

Expand Down Expand Up @@ -130,6 +130,7 @@ Block explorer URL: <empty>
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:

```
Address: 0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac
Private key: 0x5fb92d6e98884f76de468fa3f6278f8807c48bebc13595d45af5bdc4da702133
Expand Down Expand Up @@ -160,9 +161,9 @@ contract TestCounter {

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.
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.
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.

Expand Down
18 changes: 9 additions & 9 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ As above, please DO NOT include attachments or provide detail regarding the secu
## Incident Response Process

1. Establish a new draft security advisory
1. In response to an email to [security@gluwa.com](mailto:security@gluwa.com), a member of the Creditcoin team will create a new draft security advisory for the incident at [https://github.com/gluwa/creditcoin-next/security/advisories](https://github.com/gluwa/creditcoin-next/security/advisories).
2. Add the reporter's GitHub account and relevant individuals to the draft security advisory.
3. Respond to the reporter by email, sharing a link to the draft security advisory.
1. In response to an email to [security@gluwa.com](mailto:security@gluwa.com), a member of the Creditcoin team will create a new draft security advisory for the incident at [https://github.com/gluwa/creditcoin-next/security/advisories](https://github.com/gluwa/creditcoin-next/security/advisories).
2. Add the reporter's GitHub account and relevant individuals to the draft security advisory.
3. Respond to the reporter by email, sharing a link to the draft security advisory.
2. Reporter should add appropriate content to the draft security advisory to help the team resolve the issue. This includes:
1. A clear description of the issue and the impacted areas.
2. The code and the methodology to reproduce the underlying issue.
3. Discussion of potential remediations.
1. A clear description of the issue and the impacted areas.
2. The code and the methodology to reproduce the underlying issue.
3. Discussion of potential remediations.
3. Triage
1. Validate the issue.
2. Determine the criticality of the issue.
3. If this is a bug and not a security issue, recommend to the submitter to create an issue.
1. Validate the issue.
2. Determine the criticality of the issue.
3. If this is a bug and not a security issue, recommend to the submitter to create an issue.
4. Release a new version resolving the issue
126 changes: 62 additions & 64 deletions examples/contract-erc20/create-erc20-rpc.ts
Original file line number Diff line number Diff line change
@@ -1,83 +1,81 @@
import Web3 from "web3";
import * as web3Utils from 'web3-utils';
import * as web3Utils from "web3-utils";

const web3 = new Web3("http://127.0.0.1:9933");
const ERC20_BYTECODE = require("./truffle/contracts/MyToken.json").bytecode;
const STORAGE_SLOT = "0";

const createAccount = () => {
const account = web3.eth.accounts.create();
const mapStorageSlot = STORAGE_SLOT.padStart(64, '0');
const mapKey = account.address.toString().substring(2).padStart(64, '0');
const storageKey = web3Utils.sha3('0x'.concat(mapKey.concat(mapStorageSlot)));
return {...account, storageKey};
}
const account = web3.eth.accounts.create();
const mapStorageSlot = STORAGE_SLOT.padStart(64, "0");
const mapKey = account.address.toString().substring(2).padStart(64, "0");
const storageKey = web3Utils.sha3("0x".concat(mapKey.concat(mapStorageSlot)));
return { ...account, storageKey };
};

const main = async () => {
console.log("Generating accounts...");
const alice = createAccount();
const bob = createAccount();

console.log("Generating accounts...");
const alice = createAccount();
const bob = createAccount();

// Step 1: Creating the contract.
console.log(`Alice account: ${alice.address}\n storageKey [slot ${STORAGE_SLOT}]: ${alice.storageKey}`);
console.log(`Bob account: ${bob.address}\n storageKey [slot ${STORAGE_SLOT}]: ${bob.storageKey}`);
// Step 1: Creating the contract.
console.log(
`Alice account: ${alice.address}\n storageKey [slot ${STORAGE_SLOT}]: ${alice.storageKey}`,
);
console.log(
`Bob account: ${bob.address}\n storageKey [slot ${STORAGE_SLOT}]: ${bob.storageKey}`,
);

console.log(`\nCreating contract using Eth RPC "sendTransaction" from alice`);
const createTransaction = await alice.signTransaction(
{
data: ERC20_BYTECODE,
value: "0x00",
gasPrice: "0x00",
gas: "0x100000",
});
console.log("Transaction", {
...createTransaction,
rawTransaction: `${createTransaction.rawTransaction.substring(
0,
32
)}... (${createTransaction.rawTransaction.length} length)`,
});
console.log(`\nCreating contract using Eth RPC "sendTransaction" from alice`);
const createTransaction = await alice.signTransaction({
data: ERC20_BYTECODE,
value: "0x00",
gasPrice: "0x00",
gas: "0x100000",
});
console.log("Transaction", {
...createTransaction,
rawTransaction: `${createTransaction.rawTransaction.substring(0, 32)}... (${
createTransaction.rawTransaction.length
} length)`,
});

const createReceipt = await web3.eth.sendSignedTransaction(
createTransaction.rawTransaction
);
console.log(
`Contract deployed at address ${createReceipt.contractAddress}`
);
const createReceipt = await web3.eth.sendSignedTransaction(
createTransaction.rawTransaction,
);
console.log(`Contract deployed at address ${createReceipt.contractAddress}`);

// Step 2: Sending contract tokens to bob
console.log(`\nSending 221 Contract tokens from alice to bob`);
const transferFnCode = `a9059cbb000000000000000000000000`;
const tokensToTransfer = `00000000000000000000000000000000000000000000000000000000000000dd`;
const inputCode = `0x${transferFnCode}${bob.address.substring(
2
)}${tokensToTransfer}`;
// Step 2: Sending contract tokens to bob
console.log(`\nSending 221 Contract tokens from alice to bob`);
const transferFnCode = `a9059cbb000000000000000000000000`;
const tokensToTransfer = `00000000000000000000000000000000000000000000000000000000000000dd`;
const inputCode = `0x${transferFnCode}${bob.address.substring(
2,
)}${tokensToTransfer}`;

const transferTransaction = await alice.signTransaction(
{
to: createReceipt.contractAddress,
data: inputCode,
value: "0x00",
gasPrice: "0x00",
gas: "0x100000",
});
console.log("Transaction", {
...transferTransaction,
rawTransaction: `${transferTransaction.rawTransaction.substring(
0,
32
)}... (${transferTransaction.rawTransaction.length} length)`,
});
const transferTransaction = await alice.signTransaction({
to: createReceipt.contractAddress,
data: inputCode,
value: "0x00",
gasPrice: "0x00",
gas: "0x100000",
});
console.log("Transaction", {
...transferTransaction,
rawTransaction: `${transferTransaction.rawTransaction.substring(
0,
32,
)}... (${transferTransaction.rawTransaction.length} length)`,
});

const transferReceipt = await web3.eth.sendSignedTransaction(
transferTransaction.rawTransaction
);
console.log(
`Transfer executed to ${transferReceipt.to} (H: ${transferReceipt.transactionHash})`
);
const transferReceipt = await web3.eth.sendSignedTransaction(
transferTransaction.rawTransaction,
);
console.log(
`Transfer executed to ${transferReceipt.to} (H: ${transferReceipt.transactionHash})`,
);
};

main().catch((err) => {
console.log("Error", err);
console.log("Error", err);
});
Loading

0 comments on commit 6d76d64

Please sign in to comment.