Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ethereum updates #4

Merged
merged 12 commits into from
Jul 28, 2024
16 changes: 10 additions & 6 deletions book/build-your-staking-dapp/avalanche/overview.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
# Overview

Staking on the Avalanche network (AVAX) involves locking up tokens to support the network's security and operations. In return, stakers earn rewards.

{% hint style="info" %}
The Avalanche blockchain, renowned for its rapid transaction processing, low fees, and eco-friendly architecture, utilizes a unique consensus protocol known as Avalanche Consensus. This protocol enables a high degree of decentralization and security, allowing validators to participate by staking AVAX, the network's native token.
{% endhint %}

Staking on the Avalanche network (AVAX) involves locking up tokens to support the network's security and operations. In return, stakers earn rewards.

The **Chorus One SDK** simplifies this process, providing developers with the tools needed to build, sign, and broadcast staking transactions.

This guide will walk you through the fundamentals of staking on Avalanche using the Chorus One SDK.

{% hint style="info" %}

**Compatibility Notice**

The methods provided in this documentation are compatible with popular Avalanche libraries such as `@avalabs/avalanchejs`. This compatibility ensures that you can seamlessly integrate these methods into your existing Avalanche projects.

{% endhint %}

## Setting Up the Staker

To get started with staking on the Avalanche network using the Chorus One SDK, you will first need to initialize the SDK.
Expand Down Expand Up @@ -139,10 +147,6 @@ const { status, receipt } = await staker.getTxStatus({ txId, chain: 'P' })
console.log(status) // 'success'
```

{% hint style="info" %}
The signature of these methods is compatible with the methods provided by popular Avalanche libraries like `@avalabs/avalanchejs`.
{% endhint %}

---

## Next Steps
Expand Down
12 changes: 8 additions & 4 deletions book/build-your-staking-dapp/cosmos/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ The **Chorus One SDK** simplifies this process, providing developers with the to

This guide will walk you through the fundamentals of staking on Cosmos using the Chorus One SDK.

{% hint style="info" %}

**Compatibility Notice**

The methods provided in this documentation are compatible with popular Cosmos libraries such as `@cosmjs/cosmwasm`. This compatibility ensures that you can seamlessly integrate these methods into your existing Cosmos projects.

{% endhint %}

## Setting Up the Staker

To get started with staking on the Cosmos network using the Chorus One SDK, you will first need to initialize the SDK for Cosmos.
Expand Down Expand Up @@ -107,10 +115,6 @@ const signedTx = TxRaw.encode(rawTx).finish()

Additionally, you can use the Chorus One SDK to sign transactions using Fireblocks, mnemonic or other methods.

{% hint style="info" %}
The signature of these methods is compatible with the methods provided by popular Cosmos libraries like `@cosmjs/cosmwasm`.
{% endhint %}

For detailed information on setting up and configuring these options, refer to the [What is a Signer?](../../signers-explained/what-is-a-signer.md) section.

{% tabs %}
Expand Down
95 changes: 90 additions & 5 deletions book/build-your-staking-dapp/ethereum/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ To enhance efficiency, the SDK leverages [Stakewise V3's](https://docs.stakewise

This guide will walk you through the fundamentals of staking on Ethereum using the Chorus One SDK.

{% hint style="info" %}

**Compatibility Notice**

The methods provided in this documentation are compatible with popular Ethereum libraries such as `Ethers` and `viem`. This compatibility ensures that you can seamlessly integrate these methods into your existing Ethereum projects.

{% endhint %}

## Understanding Key Concepts

<details>
Expand Down Expand Up @@ -113,6 +121,23 @@ const { tx } = await staker.buildStakeTx({
})
```

### Ensuring Correct Amount Format for Staking

The `amount` parameter must be a string representing the amount of ETH to deposit. For example, `'1'` represents 1 ETH.

If you have the amount as a `bigint`, convert it to a string using the `formatEther` function from `viem`. Example:

```typescript
import { formatEther } from 'viem'

const amountBigInt = 10000000000000000n // 0.01 ETH
const amountToStake = formatEther(amountBigInt)

console.log(amountToStake) // "0.01"
```

This ensures the `amountToStake` parameter is in the correct format for the staking transaction function.

---

## Getting the Validator Address provided by Chorus One
Expand Down Expand Up @@ -142,12 +167,63 @@ Once the transaction is built, you can sign that transaction using your own sign
const signedTx = await yourWalletClient.signTransaction(tx)
```

When using your own signer, you will need to calculate the transaction fees yourself before signing.

Additionally, you can use the Chorus One SDK to sign transactions using Fireblocks, mnemonic or other methods.

- For detailed information on setting up and configuring these options, please refer to the [What is a Signer?](../../signers-explained/what-is-a-signer.md) section.

{% tabs %}

{% tab title="Using wagmi/Viem for Signing" %}
By integrating wagmi, you can take advantage of its lightweight developer-friendly wallet client capabilities to sign transactions on the Ethereum network:

```javascript
import { useWalletClient } from 'wagmi'

const { data: walletClient } = useWalletClient()

// Prepare the transaction and estimate the gas fees
const request = await walletClient.prepareTransactionRequest(tx)

// Sign and broadcast the transaction
const hash = await walletClient.sendTransaction(request)
```

For more information please refer to the [Viem Documentation](https://viem.sh/)

{% endtab %}

{% tab title="Using Ethers for Signing" %}

By integrating Ethers, you can use its widely adopted and feature-rich library for signing transactions on the Ethereum network:

```javascript
import { BrowserProvider } from 'ethers'

const provider = new BrowserProvider(window.ethereum)
const signer = await provider.getSigner()

// Estimate gas fees
const feeData = await provider.getFeeData()
const gasLimit = await provider.estimateGas(tx)

// Sign and broadcast the transaction
const { hash } = await signer.sendTransaction({
...tx,
// Optional: Set the gas limit and fees
gasLimit: gasLimit,
maxFeePerGas: feeData.maxFeePerGas,
maxPriorityFeePerGas: feeData.maxPriorityFeePerGas
})
```

For more information please refer to the [Ethers Documentation](https://docs.ethers.org/)

{% endtab %}

{% tab title="Using Fireblocks for Signing" %}

By integrating Fireblocks, you can leverage its robust security features to sign transactions on the Ethereum network. To set up Fireblocks, you will need to provide the necessary API key, secret key, and vault ID:

```javascript
Expand All @@ -164,15 +240,28 @@ const signer = new FireblocksSigner({

await signer.init()

// Just sign the transaction
const { signedTx } = await staker.sign({
signer,
signerAddress: '0x70aEe8a9099ebADB186C2D530F72CF5dC7FE6B30',
tx
tx,
baseFeeMultiplier: 2, // Optional: Multiplier for the base fee per gas
defaultPriorityFee: '2' // Optional: Override for the maxPriorityFeePerGas
})
```

### Configuring Transaction Fees

When signing transactions, you can optionally configure the fees to manage cost and priority. The `fees` parameter allows you to specify a `baseFeeMultiplier` and a `defaultPriorityFee`.

- **`baseFeeMultiplier`**: (Optional) This multiplier helps manage fee fluctuations by adjusting the base fee per gas from the latest block. For example, if the `baseFeeMultiplier` is set to 2, the final `maxFeePerGas` will be 2 times the base fee. The default value is 1.2.

- **`defaultPriorityFee`**: (Optional) This value allows you to override the `maxPriorityFeePerGas` estimated by the RPC. You can specify a fixed value to ensure that your transaction has a certain priority. By default, the `maxPriorityFeePerGas` is calculated by the RPC.

For more information please refer to the [Signing with Fireblocks](../../signers-explained/fireblocks.md)

{% endtab %}

{% endtabs %}

---
Expand All @@ -193,10 +282,6 @@ const { status, receipt } = await staker.getTxStatus({ txHash })
console.log(status) // 'success'
```

{% hint style="info" %}
The signature of these methods is compatible with the methods provided by popular Ethereum libraries like `viem`.
{% endhint %}

---

## Next Steps
Expand Down
12 changes: 8 additions & 4 deletions book/build-your-staking-dapp/near/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ The **Chorus One SDK** simplifies this process, providing developers with the to

This guide will walk you through the fundamentals of staking on NEAR using the Chorus One SDK.

{% hint style="info" %}

**Compatibility Notice**

The methods provided in this documentation are compatible with popular NEAR libraries such as `near-api-js`. This compatibility ensures that you can seamlessly integrate these methods into your existing NEAR projects.

{% endhint %}

## Setting Up the Staker

To get started with staking on the NEAR network using the Chorus One SDK, you will first need to initialize the SDK for NEAR.
Expand Down Expand Up @@ -151,10 +159,6 @@ const { status, receipt } = await staker.getTxStatus({
console.log(status) // 'success'
```

{% hint style="info" %}
The signature of these methods is compatible with the methods provided by popular NEAR libraries like `near-api-js`.
{% endhint %}

---

## Next Steps
Expand Down
12 changes: 8 additions & 4 deletions book/build-your-staking-dapp/polkadot-substrate/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ The **Chorus One SDK** simplifies this process, providing developers with the to

This guide will walk you through the fundamentals of staking on Substrate using the Chorus One SDK.

{% hint style="info" %}

**Compatibility Notice**

The methods provided in this documentation are compatible with popular Substrate libraries such as `@polkadot/api`. This compatibility ensures that you can seamlessly integrate these methods into your existing Substrate projects.

{% endhint %}

## Setting Up the Staker

To get started with staking on the Substrate network using the Chorus One SDK, you will first need to initialize the SDK for Substrate.
Expand Down Expand Up @@ -145,10 +153,6 @@ const { status, receipt } = await staker.getTxStatus({ txHash })
console.log(status) // 'success'
```

{% hint style="info" %}
The signature of these methods is compatible with the methods provided by popular Substrate libraries like `@polkadot/api`.
{% endhint %}

## Closing the Connection

After completing the staking operations, close the connection to the Substrate network:
Expand Down
12 changes: 8 additions & 4 deletions book/build-your-staking-dapp/solana/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ The **Chorus One SDK** simplifies the staking process on the Solana network, pro

This guide will walk you through the fundamentals of staking on Solana using the Chorus One SDK.

{% hint style="info" %}

**Compatibility Notice**

The methods provided in this documentation are compatible with popular Solana libraries such as `@solana/web3.js`. This compatibility ensures that you can seamlessly integrate these methods into your existing Solana projects.

{% endhint %}

## Setting Up the Staker

To get started with staking on the Solana network using the Chorus One SDK, you will first need to initialize the SDK.
Expand Down Expand Up @@ -147,10 +155,6 @@ const { status, receipt } = await staker.getTxStatus({ txHash })
console.log(status) // 'success'
```

{% hint style="info" %}
The signature of these methods is compatible with the methods provided by popular Solana libraries like `@solana/web3.js`.
{% endhint %}

---

## Next Steps
Expand Down
12 changes: 8 additions & 4 deletions book/build-your-staking-dapp/ton/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ It supports:

This guide will walk you through the fundamentals of staking on TON using the Chorus One SDK.

{% hint style="info" %}

**Compatibility Notice**

The methods provided in this documentation are compatible with popular TON libraries such as `@ton/ton`. This compatibility ensures that you can seamlessly integrate these methods into your existing TON projects.

{% endhint %}

## Setting Up the Staker

To get started with staking on TON using the Chorus One SDK, you will first need to initialize the SDK.
Expand Down Expand Up @@ -175,10 +183,6 @@ const { status, receipt } = await staker.getTxStatus({
console.log(status) // 'success'
```

{% hint style="info" %}
The signature of these methods is compatible with the methods provided by popular TON libraries like `@ton/ton`.
{% endhint %}

---

## Next Steps
Expand Down
10 changes: 6 additions & 4 deletions book/docs/classes/ethereum_src.EthereumStaker.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Builds a staking transaction.
| `params` | `Object` | Parameters for building the transaction |
| `params.delegatorAddress` | \`0x$\{string}\` | The delegator (wallet) address to stake from |
| `params.validatorAddress` | \`0x$\{string}\` | The validator (vault) address to stake with |
| `params.amount` | `string` | The amount to stake, specified in `ETH` |
| `params.amount` | `string` | The amount to stake, specified in `ETH`. E.g. "1" - 1 ETH |
| `params.referrer?` | \`0x$\{string}\` | (Optional) The address of the referrer. This is used to track the origin of transactions, providing insights into which sources or campaigns are driving activity. This can be useful for analytics and optimizing user acquisition strategies |

### Returns
Expand Down Expand Up @@ -136,7 +136,7 @@ method.
| `params` | `Object` | Parameters for building the transaction |
| `params.delegatorAddress` | \`0x$\{string}\` | The delegator (wallet) address that is unstaking |
| `params.validatorAddress` | \`0x$\{string}\` | The validator (vault) address to unstake from |
| `params.amount` | `string` | The amount to unstake, specified in `ETH` |
| `params.amount` | `string` | The amount to unstake, specified in `ETH`. E.g. "1" - 1 ETH |

### Returns

Expand Down Expand Up @@ -186,7 +186,7 @@ Builds a mint transaction.
| `params` | `Object` | Parameters for building the transaction |
| `params.delegatorAddress` | \`0x$\{string}\` | The delegator (wallet) address |
| `params.validatorAddress` | \`0x$\{string}\` | The validator (vault) address to mint shares for |
| `params.amount` | `string` | The amount to mint, specified in `osETH` |
| `params.amount` | `string` | The amount to mint, specified in `osETH`. E.g. "1" - 1 osETH |
| `params.referrer?` | \`0x$\{string}\` | (Optional) The address of the referrer. This is used to track the origin of transactions, providing insights into which sources or campaigns are driving activity. This can be useful for analytics and optimizing user acquisition strategies. |

### Returns
Expand All @@ -210,7 +210,7 @@ Builds a burn transaction.
| `params` | `Object` | Parameters for building the transaction |
| `params.delegatorAddress` | \`0x$\{string}\` | The delegator (wallet) address |
| `params.validatorAddress` | \`0x$\{string}\` | The validator (vault) address to burn shares from |
| `params.amount` | `string` | The amount to burn, specified in `osETH` |
| `params.amount` | `string` | The amount to burn, specified in `osETH`. E.g. "1" - 1 osETH |

### Returns

Expand Down Expand Up @@ -415,6 +415,8 @@ Signs a transaction using the provided signer.
| `params.signer` | `Signer` | A signer instance. |
| `params.signerAddress` | \`0x$\{string}\` | The address of the signer |
| `params.tx` | [`Transaction`](../interfaces/ethereum_src.Transaction.md) | The transaction to sign |
| `params.baseFeeMultiplier?` | `number` | (Optional) The multiplier for fees, which is used to manage fee fluctuations, is applied to the base fee per gas from the latest block to determine the final `maxFeePerGas`. The default value is 1.2. |
| `params.defaultPriorityFee?` | `string` | (Optional) This overrides the the `maxPriorityFeePerGas` estimated by the RPC. |

### Returns

Expand Down
9 changes: 0 additions & 9 deletions book/docs/interfaces/ethereum_src.Transaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,12 @@ Represents an Ethereum transaction.

### Properties

- [account](ethereum_src.Transaction.md#account)
- [to](ethereum_src.Transaction.md#to)
- [value](ethereum_src.Transaction.md#value)
- [data](ethereum_src.Transaction.md#data)

## Properties

### account

• **account**: \`0x$\{string}\`

The account (sender) address in hexadecimal format.

___

### to

• **to**: \`0x$\{string}\`
Expand Down
Loading
Loading