Skip to content
2 changes: 1 addition & 1 deletion docs/staking-api/cosmos-hub/_category_.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "Cosmos Hub",
"position": 4,
"position": 6,
"link": {
"type": "doc",
"id": "staking-api/cosmos-hub/index"
Expand Down
2 changes: 1 addition & 1 deletion docs/staking-api/cosmos-hub/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ This section covers Cosmos Hub staking integrations using the Stakely Staking AP

## Notes

- Cosmos integrations require specifying the correct `chain_id` for the target network. The API provides a dedicated endpoint to list all available Cosmos networks and their corresponding `chain_id` values.
- Cosmos integrations require specifying the correct `X-NETWORK` for the target network. The API provides a dedicated endpoint to list all available Cosmos networks and their corresponding `X-NETWORK` values.
- All staking operations are executed on-chain. Stakely prepares the transaction payloads, while signing is performed by your application using your preferred signing method.
4 changes: 2 additions & 2 deletions docs/staking-api/cosmos-hub/native-staking/_category_.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"label": "Native Staking",
"position": 3,
"link": {
"type": "generated-index",
"description": "Cosmos Hub Native Staking Module"
"type": "doc",
"id": "staking-api/cosmos-hub/native-staking/index"
}
}
36 changes: 18 additions & 18 deletions docs/staking-api/cosmos-hub/native-staking/endpoints.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 2
sidebar_position: 1
---

import StakingOpenApiLink from '@site/src/components/StakingOpenApiLink';
Expand All @@ -14,7 +14,7 @@ Once you already have access to the Staking API with a validated user and existi
:::tip

You can check the **Staking API Reference** here:
- Rendered [doc page](/staking-api/api-reference).
- Rendered <a href="/staking-api/api-reference" target="_blank" rel="noopener noreferrer">doc page</a>.
- <StakingOpenApiLink />
:::

Expand Down Expand Up @@ -45,7 +45,7 @@ Need support for another network? Reach out at [admin@stakely.io](mailto:admin@s

If you are unsure which Cosmos networks are enabled for your account you can ask the API directly.

- Endpoint: [`/api/v1/cosmos/native/networks`](/staking-api/api-reference#tag/cosmoshub/GET/api/v1/cosmoshub/native/networks)
- Endpoint: <a href="/staking-api/api-reference#tag/cosmoshub/GET/api/v1/cosmoshub/native/networks" target="_blank" rel="noopener noreferrer"><code>/api/v1/cosmoshub/native/networks</code></a>
Each object in the response includes:

| Field | Description |
Expand All @@ -61,96 +61,96 @@ ____

Craft a stake transaction:

- Endpoint: [`/api/v1/cosmos/native/action/stake`](/staking-api/api-reference#tag/cosmoshub/POST/api/v1/cosmoshub/native/action/stake)
- Endpoint: <a href="/staking-api/api-reference#tag/cosmoshub/POST/api/v1/cosmoshub/native/action/stake" target="_blank" rel="noopener noreferrer"><code>/api/v1/cosmoshub/native/action/stake</code></a>

#### Description

This endpoint will craft a stake transaction ready to be signed.

#### Request body parameters

[`StakeActionDto`](/staking-api/api-reference#model/stakeactiondto)
<a href="/staking-api/api-reference#model/stakeactiondto" target="_blank" rel="noopener noreferrer"><code>StakeActionDto</code></a>

#### Returned

[`StakingActionResponseDto`](/staking-api/api-reference#model/stakingactionresponsedto)
<a href="/staking-api/api-reference#model/stakingactionresponsedto" target="_blank" rel="noopener noreferrer"><code>StakingActionResponseDto</code></a>

____

### Unstake action

Craft an unstake transaction:

- Endpoint: [`/api/v1/cosmos/native/action/unstake`](/staking-api/api-reference#tag/cosmoshub/POST/api/v1/cosmoshub/native/action/unstake)
- Endpoint: <a href="/staking-api/api-reference#tag/cosmoshub/POST/api/v1/cosmoshub/native/action/unstake" target="_blank" rel="noopener noreferrer"><code>/api/v1/cosmoshub/native/action/unstake</code></a>

#### Description

This endpoint will craft an unstake transaction ready to be signed.

#### Request body parameters

[`UnstakeActionDto`](/staking-api/api-reference#model/unstakeactiondto)
<a href="/staking-api/api-reference#model/unstakeactiondto" target="_blank" rel="noopener noreferrer"><code>UnstakeActionDto</code></a>

#### Returned

[`StakingActionResponseDto`](/staking-api/api-reference#model/stakingactionresponsedto)
<a href="/staking-api/api-reference#model/stakingactionresponsedto" target="_blank" rel="noopener noreferrer"><code>StakingActionResponseDto</code></a>

____

### Claim rewards action

Craft a claim rewards transaction:

- Endpoint: [`/api/v1/cosmos/native/action/claim-rewards`](/staking-api/api-reference#tag/cosmoshub/POST/api/v1/cosmoshub/native/action/claim-rewards)
- Endpoint: <a href="/staking-api/api-reference#tag/cosmoshub/POST/api/v1/cosmoshub/native/action/claim-rewards" target="_blank" rel="noopener noreferrer"><code>/api/v1/cosmoshub/native/action/claim-rewards</code></a>

#### Description

This endpoint will craft a claim rewards transaction ready to be signed.

#### Request body parameters

[`ClaimRewardsActionDto`](/staking-api/api-reference#model/claimrewardsactiondto)
<a href="/staking-api/api-reference#model/claimrewardsactiondto" target="_blank" rel="noopener noreferrer"><code>ClaimRewardsActionDto</code></a>

#### Returned

[`StakingActionResponseDto`](/staking-api/api-reference#model/stakingactionresponsedto)
<a href="/staking-api/api-reference#model/stakingactionresponsedto" target="_blank" rel="noopener noreferrer"><code>StakingActionResponseDto</code></a>

____

### Prepare action

Gathers signature and unsigned tx:

- Endpoint: [`/api/v1/cosmos/native/action/prepare`](/staking-api/api-reference#tag/cosmoshub/POST/api/v1/cosmoshub/native/action/prepare)
- Endpoint: <a href="/staking-api/api-reference#tag/cosmoshub/POST/api/v1/cosmoshub/native/action/prepare" target="_blank" rel="noopener noreferrer"><code>/api/v1/cosmoshub/native/action/prepare</code></a>

#### Description

Prepare a signed transaction by gathering the provided signatures with the unsigned transaction hex string:

#### Request body parameters

[`PrepareActionDto`](/staking-api/api-reference#model/prepareactiondto)
<a href="/staking-api/api-reference#model/prepareactiondto" target="_blank" rel="noopener noreferrer"><code>PrepareActionDto</code></a>

#### Returned

[`PrepareActionResponseDto`](/staking-api/api-reference#model/preparectionresponsedto)
<a href="/staking-api/api-reference#model/preparectionresponsedto" target="_blank" rel="noopener noreferrer"><code>PrepareActionResponseDto</code></a>

____

### Broadcast action

Broadcast a signed transaction

- Endpoint: [`/api/v1/cosmos/native/action/broadcast`](/staking-api/api-reference#tag/cosmoshub/POST/api/v1/cosmoshub/native/action/broadcast)
- Endpoint: <a href="/staking-api/api-reference#tag/cosmoshub/POST/api/v1/cosmoshub/native/action/broadcast" target="_blank" rel="noopener noreferrer"><code>/api/v1/cosmoshub/native/action/broadcast</code></a>

#### Description

Broadcast a signed transaction. Usually you will brodcast the signed transaction returned in `prepare` previous step:

#### Request body parameters

[`BroadcastActionDto`](/staking-api/api-reference#model/brodacastactiondto)
<a href="/staking-api/api-reference#model/brodacastactiondto" target="_blank" rel="noopener noreferrer"><code>BroadcastActionDto</code></a>

#### Returned

[`BroadcastActionResponseDto`](/staking-api/api-reference#model/broadcastctionresponsedto)
<a href="/staking-api/api-reference#model/broadcastctionresponsedto" target="_blank" rel="noopener noreferrer"><code>BroadcastActionResponseDto</code></a>
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ Rewards generated from staking are not automatically added to your wallet; they
2. **Claim Rewards**: Use the `withdraw_rewards` function to transfer your accumulated staking rewards into your wallet.
3. Reinvestment or Transfer: After claiming, rewards can be reinvested by staking them with a validator or used for other transactions.

___

# Staking API Diagram
## Staking API Diagram

```mermaid
sequenceDiagram
Expand Down
3 changes: 1 addition & 2 deletions docs/staking-api/cosmos-hub/signing.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ This method is typically used in backend services, scripts, or environments wher


Complete with your own wallet private key or seed at `.env`

```
COSMOS_WALLET_SEED=
COSMOS_WALLET_PRIVATE_KEY=
Expand Down Expand Up @@ -195,4 +194,4 @@ const signature_hex = await signWithFb(unsigned_tx_hash_hex);

1. Get the `unsigned_tx_hash_hex` from any of the Stake actions `action/stake`, `action/unstake`, `action/claim-rewards`
2. Pass it to the signer code explaind below
3. Once you have the signature proceed calling `action/prepare`
3. Once you have the signature proceed calling `action/prepare`
5 changes: 3 additions & 2 deletions docs/staking-api/ethereum/_category_.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"label": "Ethereum",
"position": 4,
"link": {
"type": "generated-index",
"description": "Staking API Ethereum documentation."
"type": "doc",
"id": "staking-api/ethereum/index"
}
}
22 changes: 22 additions & 0 deletions docs/staking-api/ethereum/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: Ethereum
---

# Ethereum

This section covers Ethereum staking integrations using the Stakely Staking API. It includes Ethereum-specific notes, transaction signing examples, and the staking flows supported by Stakely.

## Useful links

- Stakely, Ethereum (ETH) staking overview: https://stakely.io/staking/ethereum-eth-staking
- Ethereum staking basics: https://ethereum.org/staking/#what-is-staking

## What you will find in this section

- **Signing transactions**: how to sign Ethereum transactions returned by the crafting endpoints, with examples for common signing setups.
- **StakeWise staking**: end-to-end flows and endpoints for delegating, claiming rewards, and undelegating on the liquid staking protocol StakeWise.

## Notes

- Ethereum integrations require specifying the correct `X-NETWORK` for the target network. The API provides a dedicated endpoint to list all available Ethereum networks and their corresponding `X-NETWORK` values.
- All staking operations are executed on-chain. Stakely prepares the transaction payloads, while signing is performed by your application using your preferred signing method.
12 changes: 0 additions & 12 deletions docs/staking-api/ethereum/network-information.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
---
sidebar_position: 6
sidebar_position: 2
title: Signing
---
# How to sign
# How to sign transactions

Once you have completed the first action of the flow (as explained in the diagram), you will need to sign the unsigned transaction.
After calling a crafting endpoint, the API returns an unsigned Ethereum transaction payload. This payload must be signed before it can be broadcast to the network.

There are several ways to achieve this. We will explain a couple of them:
Signing is fully handled by your application. The Stakely Staking API never has access to private keys.

## Signing with private key
The signing concepts and examples described in this section apply to all Ethereum staking flows supported by the API, regardless of the specific staking method used.

### Signing with Web3 JS using a Private Key:
Below are common signing approaches supported by Ethereum tooling.

This method involves the use of the Web3 JavaScript library, which allows developers to interact with the Ethreum virtual machine directly from a JavaScript application. To sign a transaction, a developer typically imports the SDK, creates a transaction object, and then uses a private key to sign this object. This signing process is crucial as it verifies the identity of the transaction initiator and ensures the transaction cannot be altered without the initiator's consent.
## Signing with a private key

### Signing with Ethers JS using a Private Key:

This approach uses Ethereum JavaScript libraries to sign transactions locally with a private key.

The crafted transaction payload returned by the API is passed to the signer, which produces a valid Ethereum signature. The resulting signed transaction can then be broadcast to the network.

This method is typically used in backend services, scripts, or environments where private keys are managed directly by the application.

It involves the use of the Ethers JavaScript library, which allows developers to interact with the Ethereum virtual machine directly from a JavaScript application. To sign a transaction, a developer typically imports the SDK, creates a transaction object, and then uses a private key to sign this object. This signing process is crucial as it verifies the identity of the transaction initiator and ensures the transaction cannot be altered without the initiator's consent.

Complete with your own wallet private key or seed at `.env`

Expand All @@ -24,7 +35,6 @@ EVM_CHAIN_ID=

```javascript
const { Common, Chain, Hardfork } = require('@ethereumjs/common')
const { Web3 } = require('web3');
const Transaction = require('@ethereumjs/tx');
const { RLP } = require('@ethereumjs/rlp');

Expand All @@ -40,11 +50,10 @@ const accountFrom = {
chainId: process.env.EVM_CHAIN_ID
};

const web3 = new Web3(ETHEREUM_RPC);
const common = new Common({ chain: accountFrom.chainId })

const signUnsignedTxWithPk = async ({serialized_tx_hex, raw_tx_hex_hash}) => {
const serializedTxBytes = await web3.utils.hexToBytes(serialized_tx_hex);
const serializedTxBytes = ethers.getBytes(serialized_tx_hex);
const rawTxHexHashWithoutPrefix = raw_tx_hex_hash.substring(2);

const txObject = Transaction.TransactionFactory.fromSerializedData(serializedTxBytes, { common });
Expand Down Expand Up @@ -85,19 +94,17 @@ const signature = await signUnsignedTxWithPk({serialized_tx_hex, raw_tx_hex_hash
3. Once you have the signature proceed calling `action/prepare`


## Signing by using external custodian integration
## Signing using external custodians or MPC wallets

### Fireblocks

Using external custodian services such as [Fireblocks](https://www.fireblocks.com/) provides an additional layer of security for transaction signing.
Transactions can also be signed using external custodians or MPC-based wallets. In this setup, private keys are never exposed to the application and signing is delegated to the external signing service.

Fireblocks, as a custodian, manages the private keys on behalf of the user, ensuring they are stored securely and are not exposed during the transaction process.
### Fireblocks

To sign a transaction, the transaction details are sent to Fireblocks via its API.
Fireblocks is an example of a third-party custodian that can be used to sign Ethereum transactions generated by the Stakely Staking API.

Fireblocks then signs the transaction securely within its infrastructure and returns the signed transaction, ready for submission to the blockchain network.
The crafted transaction payload is submitted to Fireblocks through its API. Fireblocks performs the signing operation within its secure environment and returns a signed transaction, which can then be broadcast to the blockchain network.

On the code example we will be providing a Javascript example with the usage of [Fireblocks SDK JS/TS](https://github.com/fireblocks/fireblocks-sdk-js)
The following code example demonstrates this flow using the Fireblocks JavaScript/TypeScript SDK.


Complete with your own Fireblocks credentials at `.env`
Expand Down Expand Up @@ -191,4 +198,4 @@ const signature_hex = await signWithFb(raw_tx_hex_hash);

1. Get the `unsigned_tx_hash_hex` from any of the Stake actions
2. Pass it to the signer code explaind below
3. Once you have the signature proceed calling `action/prepare`
3. Once you have the signature proceed calling `action/prepare`
8 changes: 0 additions & 8 deletions docs/staking-api/ethereum/stakewise-staking/_category_.json

This file was deleted.

Loading