stellar-api
stellar-api copied to clipboard
How do increase transaction fee?
How do increase transaction fee?
It's currently hardcoded in. I have some significant modifications to the repo internally that I'll eventually push. In the meantime, what you're looking for is adding this method to src/Transaction/TransactionBuilder.php
:
/**
* Allow for adjustable fee.
*
* @param $fee
*/
public function setFee($fee)
{
if (!is_int($fee) || ($fee < 100)) {
$this->baseFee = 100;
} else {
$this->baseFee = $fee;
}
return $this;
}
Here's example usage for you where fee is in stroops with a default of 100
:
$server = Server::testNet();
$transaction = $server
->buildTransaction($sourceAccountPublicKey)
->setFee(5000)
->addOperation(
new CreateAccountOp($newAccountPublicKey, 151, $sourceAccountPublicKey)
);
Note that adjusting this fee is on a per operation basis. The total fee of a transaction is calculated as baseFee * operationsCount
.