I'm getting an op_cannot_claim error code, when trying to claim claimable balance.

I've checked the docs, they don't mention this error code at all.

let account = await server.loadAccount(pairA.publicKey());

// Create a claimable balance with our two above-described conditions.
let soon = Math.ceil(Date.now() / 1000 + 60); // .now() is in ms
let bCanClaim = Stellar.Claimant.predicateBeforeRelativeTime("60");
let aCanReclaim = Stellar.Claimant.predicateNot(

// Create the operation and submit it in a transaction.
let claimableBalanceEntry = Stellar.Operation.createClaimableBalance({
  claimants: [
    new Stellar.Claimant(pairB.publicKey(), bCanClaim),
    new Stellar.Claimant(pairA.publicKey(), aCanReclaim),
  asset: Stellar.Asset.native(),
  amount: "420",

let tx = new Stellar.TransactionBuilder(account, { fee: Stellar.BASE_FEE })

// signing transaction
var keypair = Stellar.Keypair.fromSecret(pairA.secret());

  .then(function () {
    console.log("Claimable balance created!");
  .catch(function (err) {
    console.error(`Tx submission failed: ${err}`);

let balances = await server
  .limit(1) // there may be many in general
  .order("desc") // so always get the latest one
  .catch(function (err) {
   console.error(`Claimable balance retrieval failed: ${err}`);

let balanceId = balances.records[0].id;

let claimBalance = Stellar.Operation.claimClaimableBalance({
  balanceId: balanceId,

console.log(pairB.publicKey(), "claiming", balanceId);

let tx1 = new Stellar.TransactionBuilder(account, { fee: Stellar.BASE_FEE })

let key = Stellar.Keypair.fromSecret(pairA.secret());

server.submitTransaction(tx1).catch(function (err) {


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.