1

When trying to build a program with this function (from one of the exmaples given):

    function transferSolWithCpi(uint64 lamports) public {
        AccountInfo from = tx.accounts[0]; // first account must be an account owned by the program
        AccountInfo to = tx.accounts[1]; // second account must be the intended recipient

        print("From: {:}".format(from.key));
        print("To: {:}".format(to.key));

        from.lamports -= lamports;
        to.lamports += lamports;
    }

I get a failed build saying:

error: assigning to incorrect type uint64
   ┌─ /mnt/c/<my-path>/solidity/tryPay.sol:38:14
   │
38 │         from.lamports -= lamports;

Does anybody know how I can fix this? I copied the exact same code as in the example

2

1 Answer 1

2

Try using v0.3.2 of Solang, which seems to include the fix https://github.com/hyperledger/solang/releases/tag/v0.3.2

Solana The lamports and data fields of tx.accounts can be modified again.

1
  • Thank you, that clears it up! It worked Commented Sep 1, 2023 at 8:06

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.