Skip to content

Commit

Permalink
Merge branch 'contract-updates' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
Bobinstein committed Mar 25, 2024
2 parents f708e18 + 11b233f commit 7d8096b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 31 deletions.
34 changes: 27 additions & 7 deletions docs/src/gateways/ar-io-node/delegated-staking.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,17 @@ yarn install

## Providing Wallet

In order to update your gateway settings, you need to run the script using the wallet associated with your gateway. You can provide this wallet by saving a keyfile in the testnet-contract repo, and name the file `key.json`.
In order to update your gateway settings, you need to run the script using the wallet associated with your gateway. The easiest way to provide your wallet is to put the path to your Keyfile in your `.env` as `WALLET_FILE_PATH`

You will need a small amount of AR in this wallet, in addition to the IO tokens, in order to pay for the contract interaction.
You will need a small amount of AR in this wallet in order to pay for the contract interaction.

## Editing the Script
```js
//.env

WALLET_FILE_PATH=<path/to/wallet>
```

<!-- ## Editing the Script
You will need to edit the script to give it the correct information for when it runs. You can do this by opening the file, located at `testnet-contract > tools > update-gateway-settings.ts` in any code or text editor. Once you have the file open, you will need to look for these lines:
Expand Down Expand Up @@ -134,14 +140,28 @@ When you are done, that section should look like this:
disableBundling: true,
},
);
```
``` -->

## Running the Script

Once the above is set all that is left is to run the script. This can be done with a single command in your terminal.
Once the repo is installed and your wallet is provided, all that is left is to run the script. This can be done with a single command in your terminal.

Make sure your terminal is in the root folder of the testnet-contract repo (the one named 'testnet-contract'), and run this command:

```bash
yarn ts-node tools/update-gateway-settings.ts
```
yarn update-gateway-settings
```

You will be prompted in your terminal for the values of various settings on your gateway. The default value for each prompt will be your current setting, so if you don't want to change something, simply press `ENTER` to move to the next prompt.

- **Enter your a friendly name for your gateway**: This is a name or `label` for your gateway.
- **Enter your domain for this gateway**: This is the domain name for your gateway. It should be the full domain, without any protocol ("http/https") prefix. For example: "vilenarios.com".
- **Enter port used for this gateway**: The primary access port people should use to access your gateway. Except for some advanced use cases, this value should be 443.
- **Enter protocol used for this gateway**: http or https. Most users will want to use https.
- **Enter gateway properties transaction ID (use default if not sure)**: Arweave TxId for your gateway properties setting. This is not a widely implemented feature yet, so most people will just press `ENTER` to accept the default value.
- **Enter short note to further describe this gateway**: A short description of your gateway. Must be 256 characters or less.
- **Enter the observer wallet public address**: The public wallet address being used for your Observer. It will default to the wallet being used to join the network.
- **Enable or disable delegated staking?**: Do you want to allow people to stake tokens on your gateway? `y` for yes or `n` for no.
- **Enter the percent of gateway and observer rewards given to delegates**: What percentage of your gateway rewards do you want to give to your delegated stakers? Defaults to 10%.
- **Enter the minimum delegate stake for this gateway (in IO)**: The minimum number of tokens a person has to stake to delegate to your gateway. Defaults to 100.
- **CONFIRM GATEWAY DETAILS?**: This is your last chance to review all of your settings before submitting the transaction. `y` to confirm and submit, `n` to cancel.
43 changes: 19 additions & 24 deletions docs/src/guides/delegated-staking.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,18 @@ yarn install

## Providing Wallet

In order to send tokens to be staked, you will need to use a wallet that has IO tokens in it. You can provide this wallet by saving a keyfile in the testnet-contract repo, and name the file `key.json`.
In order to send tokens to be staked, you will need to use a wallet that has IO tokens in it. The easiest way to provide your wallet is to put the path to your Keyfile in your `.env` as `WALLET_FILE_PATH`.

You will need a small amount of AR in this wallet, in addition to the IO tokens, in order to pay for the contract interaction.

## Editing the script

```js
//.env

WALLET_FILE_PATH=<path/to/wallet>
```

<!-- ## Editing the script
You can set the number of tokens you want to stake, and the gateway where you want to stake them, by editing the file for the script. The script is located at `testnet-contract > tools > delegate-stake.ts`.
Expand All @@ -71,43 +78,31 @@ This line sets the target gateway where you want to stake the tokens. Replace th
You can find the wallet address of a gateway by going to `https://<gateway-domain-name>/ar-io/info`.
Save and exit your editor.
Save and exit your editor. -->

## Running the Script

Once the above is set all that is left is to run the script. This can be done with a single command in your terminal.
Once the repo is installed and your wallet is provided, all that is left is to run the script. This can be done with a single command in your terminal.

Make sure your terminal is in the root folder of the testnet-contract repo (the one named 'testnet-contract'), and run this command:

```bash
yarn ts-node tools/delegate-stake.ts
yarn delegate-stake
```

## Withdrawing Stake
You will be prompted in your terminal for the number of tokens you want to stake, and the wallet address of the target gateway.

If you want to take your staked tokens out of a gateway, the process is very similar. You will be editing and running the `decrease-delegate-stake.ts` file instead of the `delegate-stake.ts` file.

The structures of bot files are similar, and there are only the same two lines to edit:

```ts
const qty = 500;
```
## Withdrawing Stake

This line represents the number of tokens you want to remove from staking.
If you want to take your staked tokens out of a gateway, the process is very similar. You will be running the `decrease-delegate-stake` script instead of the `delegate-stake` script.

```ts
const target = 'QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ';
```bash
yarn decrease-delegate-stake
```

This line represents the address of the gateway you want to withdraw from.
You will again be prompted for the number of tokens you want to withdraw and the wallet address of the gateway you want to withdraw from.

Only the wallet that owns the staked tokens can withdraw, so make sure you are using the same wallet to run the script as you used to stake the tokens initially.

Run the script in the same way you ran the staking script, being sure to use the decrease file and not the staking file.

```bash
yarn ts-node tools/decrease-delegate-stake.ts
```

Token withdrawals are not instant, and there is a period where the tokens will remain unavailable after you run the script. The length of this hold may vary a bit during testnet while optimal times are iterated upon.
**NOTE**: Token withdrawals are not instant, and there is a period where the tokens will remain unavailable after you run the script. The length of this hold may vary a bit during testnet while optimal times are iterated upon.

0 comments on commit 7d8096b

Please sign in to comment.