Staking OADA
// src/oada/actions.ts
// Type definition for OADA staking requests
// Specifies the amount of OADA tokens to stake
type StakeOadaRequest = {
amount: bigint;
};// src/oada/actions.ts
// Async thunk for staking OADA tokens
// Manages the complete staking process including transaction creation, signing, and submission
export const stakeOada = createAsyncThunk<
BasicResponse<string>,
StakeOadaRequest,
{
dispatch: AppDispatch;
state: RootState;
extra: Services;
rejectValue: FailResponse;
}
>("stakeOada", async (request: StakeOadaRequest, thunkApi) => {
// Implementation details for staking OADA tokens
const wallet = thunkApi.getState().wallet.wallet!;
const [utxos, changeAddress] = await getWalletUtxos(wallet);
const ownerPkh = bech32AddressToPaymentPkh(changeAddress);
const serverRequest = {
ownerPkh,
returnAddressBech32: changeAddress,
amount: request.amount,
};
const requestOptions = {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json;charset=UTF-8",
},
body: Json.stringify(serverRequest),
};
const rawResponse = await fetch(
`${oadaEndpointsUrl}/stake-oada`,
requestOptions
);
const addFee = (recipe: TxRecipe) => {
oadaFeeAddress &&
oadaStakeFee &&
recipe.txOuts.push({
address: oadaFeeAddress,
value: { lovelace: oadaStakeFee },
datum: null,
refScript: null,
});
return recipe;
};
const signedTxResponse = await getRecipeBuildSendTx(
utxos,
changeAddress,
rawResponse,
addFee
);
return signedTxResponse;
});Staking features include:
Last updated