Skip to content

Commit

Permalink
New Crowdin updates (#729)
Browse files Browse the repository at this point in the history
  • Loading branch information
darwintree authored Sep 14, 2024
1 parent ebaf6cc commit 87fb9f6
Show file tree
Hide file tree
Showing 40 changed files with 1,078 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ If your account does not have enough balance, you will encounter the following e

## Resources

1. Check [js-conflux-sdk's documentation](https://docs.confluxnetwork.org/js-conflux-sdk/) for more details
1. Check [js-conflux-sdk's documentation](https://confluxnetwork.gitbook.io/js-conflux-sdk) for more details
2. Refer to [SDKs](./build/sdks-and-tools/sdks.md) for examples of other SDKs.
3. [Core Space Faucet](https://faucet.confluxnetwork.org/)
4. [Conflux Core Scan](https://confluxscan.io/)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Chain ID for Conflux Core Space Testnet is `1(0x1)`. The corresponding blockchai
| https://test.confluxrpc.com | HTTP | |
| https://cfxtest.confluxrpc.com | HTTP | |
| https://test.confluxrpc.org | HTTP | Backup RPC Service |
| wss://test.confluxrpc.org/com | Websocket | |
| wss://test.confluxrpc.com/ws | Websocket | |
| wss://test.confluxrpc.org/ws | Websocket | |

### Rate Limits
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ For detailed information about each field, you can refer to the API documentatio

The logs field in the Receipt is an array containing all the logs generated during the transaction execution process. When interacting with a contract, the contract can produce logs or events using emit statements. After the transaction is executed, these logs are recorded in the transaction receipt. In Solidity, [Events](https://docs.soliditylang.org/en/v0.8.23/contracts.html#events) are designed to log information about the execution of contract methods, providing detailed information about contract execution through events.

You can retrieve logs using the [cfx_getLogs](/docs/core/build/json-rpc/cfx-namespace#cfx_getlogs) method and decode the log data using the [abi.decode](https://docs.soliditylang.org/en/v0.8.23/contracts.html#events) method. Conflux SDKs also provide methods to help decoding the logs, for example, [javascript](https://docs.confluxnetwork.org/js-conflux-sdk/docs/interact_with_contract#how-to-decode-log) and [python](https://python-conflux-sdk.readthedocs.io/en/latest/examples/05-interact_with_contracts_and_process_logs.html#process-logs).
You can retrieve logs using the [cfx_getLogs](/docs/core/build/json-rpc/cfx-namespace#cfx_getlogs) method and decode the log data using the [abi.decode](https://docs.soliditylang.org/en/v0.8.23/contracts.html#events) method. Conflux SDKs also provide methods to help decoding the logs, for example, [javascript](https://confluxnetwork.gitbook.io/js-conflux-sdk/docs/interact_with_contract#how-to-decode-log) and [python](https://python-conflux-sdk.readthedocs.io/en/latest/examples/05-interact_with_contracts_and_process_logs.html#process-logs).

## Execution Failure

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The [Developer Quickstart](../core-developer-quickstart.md) demonstrates how to
- Unit Conversion
- Hashing and Signing

For further details and examples, please refer to the [js-conflux-sdk documentation](https://docs.confluxnetwork.org/js-conflux-sdk/).
For further details and examples, please refer to the [js-conflux-sdk documentation](https://confluxnetwork.gitbook.io/js-conflux-sdk).

## Account Generation

Expand Down Expand Up @@ -126,7 +126,7 @@ async function main() {
}
```

Consult the sdk's [Contract interaction guide](https://docs.confluxnetwork.org/js-conflux-sdk/docs/interact_with_contract) for more information.
Consult the sdk's [Contract interaction guide](https://confluxnetwork.gitbook.io/js-conflux-sdk/docs/interact_with_contract) for more information.

## Common Utilities

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Install the OpenZeppelin contracts for a secure, audited implementation of ERC11
npm install @openzeppelin/contracts hardhat-conflux js-conflux-sdk
```

For additional information, refer to the [Hardhat Conflux Plugin Tutorials](/docs/core/tutorials/hardhat-conflux-plugin) and [JS-Conflux-SDK Documentation](https://docs.confluxnetwork.org/js-conflux-sdk).
For additional information, refer to the [Hardhat Conflux Plugin Tutorials](/docs/core/tutorials/hardhat-conflux-plugin) and [JS-Conflux-SDK Documentation](https://confluxnetwork.gitbook.io/js-conflux-sdk).

## Step 3: Writing the Smart Contract

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ npm install @openzeppelin/contracts hardhat-conflux js-conflux-sdk
```

For additional information on the Hardhat-Conflux-Plugin, please refer to the [Hardhat Conflux Plugin Tutorials](/docs/core/tutorials/hardhat-conflux-plugin).
To learn more about the JS-Conflux-SDK, please visit the [JS-Conflux-SDK Documentation](https://docs.confluxnetwork.org/js-conflux-sdk).
To learn more about the JS-Conflux-SDK, please visit the [JS-Conflux-SDK Documentation](https://confluxnetwork.gitbook.io/js-conflux-sdk).

## Step 3: Writing the Smart Contract

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
displayed_sidebar: generalSidebar
sidebar_position: 2
---

# Security Advice for Wallet Backup

## 1. Mnemonic Phrases/Private Keys Backup

### Plaintext Mnemonic Phrases

Mnemonic phrases typically consist of 12 or 24 English words, following the BIP39 standard to ensure interoperability, for example: "witch collapse practice feed shame open despair creek road again ice least".

#### Security Recommendations:

- Consider using special "obfuscation modes", such as rearranging words alphabetically or reversing every other word
- Be cautious when replacing words; you can use synonyms or custom rules, but make sure you can remember them
- Example: Replace the 3rd, 7th, and 11th words with their antonyms

### Mnemonic Phrases with Passphrase

Passphrase, sometimes referred to as the “25th word,” enhances security by adding an extra layer of protection to the seed generation process, making brute-force attacks significantly more challenging. It’s crucial to back up both the mnemonic phrase and the passphrase securely.

#### Security Recommendations:

- Choose a strong password, avoiding birthdays, common words, etc.
- Consider using a password manager to generate and store the password
- Example: Use [1Password](https://1password.com/) to generate a strong password like `"X2$9Pz#mK@Lq"`

## 2. Advanced Backup Strategies

### Cloud Storage Backup

Advantages include easy access and multiple redundancies, but there are risks of potential hacking attacks and service provider data breaches.

#### Security Enhancement Measures:

- Use client-side encrypted cloud services like [Tresorit](https://tresorit.com/) or [Cryptomator](https://cryptomator.org/)
- Implement two-factor authentication (2FA)
- Use strong, unique passwords
- Apply additional encryption using [GPG](https://www.gnupg.org/) or [VeraCrypt](https://www.veracrypt.fr/) before uploading
- GPG encryption command example:
```
gpg --encrypt --recipient your@email.com wallet_backup.txt
```

### Advanced Paper Backups

Use waterproof, fireproof paper and consider steganography techniques to further enhance the security and privacy protection of paper backups.

#### Security Enhancement Measures:

- Use password-protected QR codes to store mnemonic phrases
- Encode mnemonic phrases as stories or drawings
- Create durable backups using professional metal etching tools
- Example: Use metal storage devices like [Cryptosteel](https://cryptosteel.com/) or [Billfodl](https://shop.ledger.com/products/the-billfodl)

### Cold Storage Devices

- Use dedicated hardware wallets like [Ledger](https://www.ledger.com/) or [Trezor](https://trezor.io/)
- Use offline computers for cold storage

#### Security Enhancement Measures:

- Regularly update firmware
- Use complex PIN codes
- Enable advanced security features, such as Ledger's anti-phishing word verification
- Consider using multiple hardware wallets stored in different locations

## 3. Backup Security Principles and Practices

### Regular Security Audits

Regularly check the integrity and accessibility of all backups, and update security measures to address new threats

#### Audit Checklist:

- Verify the readability of all backups
- Test recovery processes
- Check for hardware wallet firmware updates
- Review access controls and password strength

### Social Engineering Attack Prevention

Develop a comprehensive understanding of phishing and scam tactics to enhance your security awareness and protect your digital assets.

#### Preventive Measures:

- Never share complete mnemonic phrases or private keys online
- Use official websites and apps, verify download sources
- Be wary of unsolicited "help" on social media and instant messaging
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
displayed_sidebar: generalSidebar
sidebar_position: 1
---

# Security Advice for Creating a Wallet
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
---
displayed_sidebar: generalSidebar
---

# ERC20Permit

In standard ERC20, users typically need to execute two separate transactions:

1. **Approval (approve)**: The user authorizes a certain amount of tokens to a recipient.
2. **Transfer (transferFrom)**: The recipient transfers tokens from the user's account.

This approach not only increases gas costs but also diminishes user experience. By using ERC20Permit, we can merge these two steps into a single transaction, thereby saving gas and simplifying the process.

### Gas Optimization Comparison

**Standard ERC20 Process**

1. User calls `approve(spender, amount)`: approximately 50,000 gas
2. Recipient calls `transferFrom(owner, recipient, amount)`: approximately 65,000 gas

**Optimized Process Using ERC20Permit**

1. User generates a signature (off-chain operation, no gas cost)
2. Recipient calls `transferWithPermit` (including permit and transferFrom): approximately 80,000 gas

**Savings**: approximately 35,000 gas, equivalent to a 30% gas reduction.

### Example Code

#### Standard ERC20 Implementation

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
// Standard ERC20 implementation
contract StandardToken is ERC20 {
constructor() ERC20("StandardToken", "STD") {
_mint(msg.sender, 1000000 * 10**decimals());
}
}
```

#### Optimized Implementation Using ERC20Permit

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
contract OptimizedToken is ERC20Permit {
constructor() ERC20("OptimizedToken", "OPT") ERC20Permit("OptimizedToken") {
_mint(msg.sender, 1000000 * 10**decimals());
}
function transferWithPermit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external {
// Call permit to authorize the spender
permit(owner, spender, value, deadline, v, r, s);
// Transfer tokens from owner to msg.sender
transferFrom(owner, msg.sender, value);
}
}
```

#### Frontend Implementation

Example of implementing ERC20 Permit signature using Ethers.js v6:

```javascript
import { ethers } from "ethers";

async function signERC20Permit(contract, owner, spender, value, deadline, nonce) {
const provider = new ethers.BrowserProvider(window.ethereum);
const signer = await provider.getSigner();

const domain = {
name: await contract.name(),
version: '1',
chainId: (await provider.getNetwork()).chainId,
verifyingContract: await contract.getAddress()
};

const types = {
Permit: [
{ name: 'owner', type: 'address' },
{ name: 'spender', type: 'address' },
{ name: 'value', type: 'uint256' },
{ name: 'nonce', type: 'uint256' },
{ name: 'deadline', type: 'uint256' }
]
};

const message = {
owner,
spender,
value,
nonce,
deadline
};

const signature = await signer.signTypedData(domain, types, message);
const { v, r, s } = ethers.Signature.from(signature);

return { v, r, s };
}

// Usage example
const abi = [
"function transferWithPermit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)"
];

const provider = new ethers.BrowserProvider(window.ethereum);
const signer = await provider.getSigner();
const contract = new ethers.Contract(tokenAddress, abi, signer);

const owner = await signer.getAddress();
const spender = '0x...'; // Address to be authorized
const value = ethers.parseUnits('100', 18); // Amount to authorize
const deadline = Math.floor(Date.now() / 1000) + 60 * 60; // Expires in 1 hour
const nonce = await contract.nonces(owner);

const { v, r, s } = await signERC20Permit(contract, owner, spender, value, deadline, nonce);

// Call the transferWithPermit function of the contract
await contract.transferWithPermit(owner, spender, value, deadline, v, r, s);
```

### Advantages of ERC20Permit

- **Reduced Transaction Count**: Merges approval and transfer into a single transaction, saving gas.
- **Improved User Experience**: Token holders do not need to pay gas fees for approvals.
- **Batch Processing**: Recipients can batch multiple permit and transferFrom operations in one transaction, further reducing gas consumption.

By adopting ERC20Permit, you can create a smoother and more cost-effective token interaction experience for users while reducing the overall load on the blockchain network.

**Gas Optimization Recommendations**

🌟 In scenarios where frequent approvals and transfers are needed, consider using ERC20Permit. This can significantly reduce the number of transactions and overall gas consumption for users.
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,27 @@ Wallets supported depend on the Space you plan to interact with.

For more information about each wallet, please navigate to the corresponding section.

For the security of your wallet, you can also read the articles below.

- [Security Advice for Creating a Wallet](/docs/general/blockchain-security/create-wallet)
- [Security Advice for Wallet Backup](/docs/general/blockchain-security/backup-wallet)

If you want to learn more about Conflux supporting wallets, please checkout the following video:

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";

<Tabs>
<TabItem value="youtube" label="Conflux Wallets Walkthrough">
<iframe width="560" height="315" src="https://www.youtube.com/embed/Aur7dF1dgG8?si=gniTiB6DethdLixG" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
<iframe
width="560"
height="315"
src="https://www.youtube.com/embed/Aur7dF1dgG8?si=gniTiB6DethdLixG"
title="YouTube video player"
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
allowfullscreen
></iframe>
</TabItem>
</Tabs>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ If your account does not have enough balance, you will encounter the following e

## Resources

1. Check [js-conflux-sdk's documentation](https://docs.confluxnetwork.org/js-conflux-sdk/) for more details
1. Check [js-conflux-sdk's documentation](https://confluxnetwork.gitbook.io/js-conflux-sdk) for more details
2. Refer to [SDKs](./build/sdks-and-tools/sdks.md) for examples of other SDKs.
3. [Core Space Faucet](https://faucet.confluxnetwork.org/)
4. [Conflux Core Scan](https://confluxscan.io/)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Chain ID for Conflux Core Space Testnet is `1(0x1)`. The corresponding blockchai
| https://test.confluxrpc.com | HTTP | |
| https://cfxtest.confluxrpc.com | HTTP | |
| https://test.confluxrpc.org | HTTP | Backup RPC Service |
| wss://test.confluxrpc.org/com | Websocket | |
| wss://test.confluxrpc.com/ws | Websocket | |
| wss://test.confluxrpc.org/ws | Websocket | |

### Rate Limits
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ For detailed information about each field, you can refer to the API documentatio

The logs field in the Receipt is an array containing all the logs generated during the transaction execution process. When interacting with a contract, the contract can produce logs or events using emit statements. After the transaction is executed, these logs are recorded in the transaction receipt. In Solidity, [Events](https://docs.soliditylang.org/en/v0.8.23/contracts.html#events) are designed to log information about the execution of contract methods, providing detailed information about contract execution through events.

You can retrieve logs using the [cfx_getLogs](/docs/core/build/json-rpc/cfx-namespace#cfx_getlogs) method and decode the log data using the [abi.decode](https://docs.soliditylang.org/en/v0.8.23/contracts.html#events) method. Conflux SDKs also provide methods to help decoding the logs, for example, [javascript](https://docs.confluxnetwork.org/js-conflux-sdk/docs/interact_with_contract#how-to-decode-log) and [python](https://python-conflux-sdk.readthedocs.io/en/latest/examples/05-interact_with_contracts_and_process_logs.html#process-logs).
You can retrieve logs using the [cfx_getLogs](/docs/core/build/json-rpc/cfx-namespace#cfx_getlogs) method and decode the log data using the [abi.decode](https://docs.soliditylang.org/en/v0.8.23/contracts.html#events) method. Conflux SDKs also provide methods to help decoding the logs, for example, [javascript](https://confluxnetwork.gitbook.io/js-conflux-sdk/docs/interact_with_contract#how-to-decode-log) and [python](https://python-conflux-sdk.readthedocs.io/en/latest/examples/05-interact_with_contracts_and_process_logs.html#process-logs).

## Execution Failure

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The [Developer Quickstart](../core-developer-quickstart.md) demonstrates how to
- Unit Conversion
- Hashing and Signing

For further details and examples, please refer to the [js-conflux-sdk documentation](https://docs.confluxnetwork.org/js-conflux-sdk/).
For further details and examples, please refer to the [js-conflux-sdk documentation](https://confluxnetwork.gitbook.io/js-conflux-sdk).

## Account Generation

Expand Down Expand Up @@ -126,7 +126,7 @@ async function main() {
}
```

Consult the sdk's [Contract interaction guide](https://docs.confluxnetwork.org/js-conflux-sdk/docs/interact_with_contract) for more information.
Consult the sdk's [Contract interaction guide](https://confluxnetwork.gitbook.io/js-conflux-sdk/docs/interact_with_contract) for more information.

## Common Utilities

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Install the OpenZeppelin contracts for a secure, audited implementation of ERC11
npm install @openzeppelin/contracts hardhat-conflux js-conflux-sdk
```

For additional information, refer to the [Hardhat Conflux Plugin Tutorials](/docs/core/tutorials/hardhat-conflux-plugin) and [JS-Conflux-SDK Documentation](https://docs.confluxnetwork.org/js-conflux-sdk).
For additional information, refer to the [Hardhat Conflux Plugin Tutorials](/docs/core/tutorials/hardhat-conflux-plugin) and [JS-Conflux-SDK Documentation](https://confluxnetwork.gitbook.io/js-conflux-sdk).

## Step 3: Writing the Smart Contract

Expand Down
Loading

0 comments on commit 87fb9f6

Please sign in to comment.