Bonfida / token-vesting

A Vesting Contract for the Solana Blockchain
https://vesting.bonfida.org/
Other
252 stars 167 forks source link

failed to send transaction: Transaction simulation failed: Error processing Instruction 0: Program failed to complete #38

Closed Skelt24 closed 1 year ago

Skelt24 commented 1 year ago

Hello,

I got an issue while trying to unlock token after schedule date from JS binding.

"failed to send transaction: Transaction simulation failed: Error processing Instruction 0: Program failed to complete"

Instruction I try to add to my transaction : { "keys": [ { "pubkey": { "_bn": "06ddf6e1d765a193d9cbe146ceeb79ac1cb485ed5f5b37913a8cf5857eff00a9" }, "isSigner": false, "isWritable": false }, { "pubkey": { "_bn": "06a7d51718c774c928566398691d5eb68b5eb8a39b4b6d5c73555b2100000000" }, "isSigner": false, "isWritable": false }, { "pubkey": { "_bn": "1d8ac3243cbb34df9a039eac5742d08d22aa2dcb5f24ba38ae8984fa716b348c" }, "isSigner": false, "isWritable": true }, { "pubkey": { "_bn": "e167b68e45266d93d721d7bd47c3637e7297033a648b0e9954cb81a0f35f00e2" }, "isSigner": false, "isWritable": true }, { "pubkey": { "_bn": "21636b52572fe17e6d99d11393297c3cab290f8843e2c19e17a4dd70bcc307fe" }, "isSigner": false, "isWritable": true } ], "programId": "CChTq6PthWU82YZkbveA3WDf7s97BWhBK4Vx9bmsT743", "data": { "type": "Buffer", "data": [ 2, 86 ] } }

Mainnet IDs as example but I got the error on both networks :

Vesting Account ID : 2zKYdMw9PeJYKFb479EKn7mZNkamTb95uCTS5AJ42sZD Vesting Token Account ID : GAtTUKA9NxcQWHbUnPZoWwXkUktRYAqCWUHNnAHRwRHs

I don't understand what is wrong in the data of the nistruction.

Thank for your help in advance

dr497 commented 1 year ago

Hi @Skelt24 ! It seems like the vesting contract was created with the following destination address 3FLP6KmT2CQfMVRkDycHcbyv18GXQ6GNbd7PVx54bXY1 which is a SOL wallet address instead of a token account address.

The destination address must be a SPL token account address (ideally an associated token account) otherwise the CPI to transfer the tokens will fail https://github.com/Bonfida/token-vesting/blob/master/program/src/processor.rs#L241

Skelt24 commented 1 year ago

Hi @dr497 ! Thank you for your quick feedback. Indeed, I missunderstood and I put the pubkey during the creation process for the vesting. I corrected it but I still got the issue.

{ "keys": [ { "pubkey": { "_bn": "06ddf6e1d765a193d9cbe146ceeb79ac1cb485ed5f5b37913a8cf5857eff00a9" }, "isSigner": false, "isWritable": false }, { "pubkey": { "_bn": "06a7d51718c774c928566398691d5eb68b5eb8a39b4b6d5c73555b2100000000" }, "isSigner": false, "isWritable": false }, { "pubkey": { "_bn": "c61767ac8b8d1c968ad0dbadf2d952d49a976d54237cd07744cd05dd0a72e6d6" }, "isSigner": false, "isWritable": true }, { "pubkey": { "_bn": "517be6c708323c14e560d5470e5ff07cdd6e8b3e3979935f7007e2c2a84dedfd" }, "isSigner": false, "isWritable": true }, { "pubkey": { "_bn": "ea740d06993007aefdaf93058fe018fda75b75c2abbc7f2e200b64bc9fbaceab" }, "isSigner": false, "isWritable": true } ], "programId": "DLxB9dSQtA4WJ49hWFhxqiQkD9v6m67Yfk9voxpxrBs4", "data": { "type": "Buffer", "data": [ 2, 81 ] } }

Vesting Account ID : ELGRa7bbrfEAfycpCRXhtcVXVGVvN9wQ9i9Fww1gFg21 Vesting Token Account ID : 6V5bxBbj4erMitFojHfBuuqJzuA1HDpPtjwc1KNUtTvC

dr497 commented 1 year ago

Could you skip the preflight when you send the transaction and share the signature of the transaction? This way it will be easier to check what could be going wrong

Skelt24 commented 1 year ago

Thanks again for your feedback @dr497 . I figured it out. The issue was coming from the seed I send into the instrcution which wasn't correctly enoded into an uin8tArray.

Tx (failed) : XGQEf73QiAp8Ad63zYDA8FR2D36aJJ349Rb34XFVoWXHxnky2gfDjLB2fdkyHGi9cxc1g4mQ247mwwX5g7aCf2o

Thank you very much for your help.

dr497 commented 1 year ago

Glad to know it's solved! Will close the issue, let me know if there is anything else we can help with