Bako Gateway
Rust Examples
Upgrade Consensus
  1. Setup the URL and API Token:
const API_TOKEN: &str = "";
const BAKO_GATEWAY_URL: &str = "https://api.bako.global/v1/graphql?api_token=";
  1. Connect in the Provider:
let provider = Provider::connect(node_url.clone()).await?;
wallet.set_provider(provider.clone());
  1. Load the consensus parameters and set the new values (in this example we are setting the gas costs to zero):
// Get consensus parameters and upgrade the gas costs
let mut new_consensus_parameters = provider.chain_info().await?.consensus_parameters;
new_consensus_parameters.set_gas_costs(GasCosts::free());
  1. Prepare the transaction for consensus parameters upgrade:
// Prepare the upgrade transaction with the new consensus parameters
let mut builder = UpgradeTransactionBuilder::prepare_consensus_parameters_upgrade(
    &new_consensus_parameters,
    TxPolicies::default().with_max_fee(amount),
);
let base_asset_id = provider.base_asset_id();
let inputs = wallet
    .get_asset_inputs_for_amount(*base_asset_id, amount, None)
    .await?;
let outputs = wallet.get_asset_outputs_for_amount(wallet.address(), *base_asset_id, amount);
 
builder.add_signer(wallet.clone())?;
 
let tx = builder
    .with_inputs(inputs)
    .with_outputs(outputs)
    .build(provider.clone())
    .await?;
 
let tx_upgrade = Transaction::from(tx);
  1. Submit the transaction to the Gateway:
let client = FuelClient::new(node_url).unwrap();
let tx_id = client.submit(&tx_upgrade).await?;

See in context