Code Monkey home page Code Monkey logo

token-vesting's Introduction

Token vesting




Table of contents


  1. Program ID
  2. Audit
  3. UI
  4. Overview
  5. Structure

Program ID


  • mainnet: CChTq6PthWU82YZkbveA3WDf7s97BWhBK4Vx9bmsT743
  • devnet: DLxB9dSQtA4WJ49hWFhxqiQkD9v6m67Yfk9voxpxrBs4

Audit


This code has been audited by Kudelski ✅


UI


The Bonfida Token Vesting UI can be used to unlock tokens. The UI only works for vesting accounts using the mainnet deployment CChTq6PthWU82YZkbveA3WDf7s97BWhBK4Vx9bmsT743


Overview


  • Simple vesting contract (SVC) that allows you to deposit X SPL tokens that are unlocked to a specified public key at a certain block height/ slot.
  • Unlocking works by pushing a permissionless crank on the contract that moves the tokens to the pre-specified address
  • Token Address should be derived from https://spl.solana.com/associated-token-account
  • 'Vesting Schedule contract' - A contract containing an array of the SVC's that can be used to develop arbitrary- vesting schedules.
  • Tooling to easily setup vesting schedule contracts
  • Recipient address should be modifiable by the owner of the current recipient key
  • Implementation should be a rust spl compatible program, plus client side javascript bindings that include a CLI- interface. Rust program should be unit tested and fuzzed.

Structure


  • cli : CLI tool to interact with on-chain token vesting contract
  • js : JavaScript binding to interact with on-chain token vesting contract
  • program : The BPF compatible token vesting on-chain program/smart contract

diagram

token-vesting's People

Contributors

armaniferrante avatar dr497 avatar dzmitry-lahoda avatar ellttben avatar joncinque avatar setmax avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

token-vesting's Issues

cargo build-bpf not work

got error can't find crate for profiler_builtins

cargo --version --verbose
cargo 1.60.0-nightly (358e79fe5 2022-01-04)

solana --version
solana-cli 1.9.4 (src:8ce65878; feat:3258470607)

Token Lock has disappeared from the UI

Why is it no longer possible to lock tokens here?
https://vesting.bonfida.org/#/

Now only possible to unlock, and change destination. The documentation you list is all outdated, and there is no explanation for why it is not longer possible to lock tokens. Please fix this. This was working fine just 2 months ago at https://vesting.bonfida.org/#/. There was "Lock" , "Unlock" , and "Change Destination"

Now, it only gives ability to "Unlock" and "Change Destination"

What is going on?

program-id for the vesting contract?

Is it CChTq6PthWU82YZkbveA3WDf7s97BWhBK4Vx9bmsT743?
Also can we open source the UI for this? Would love to make some UI changes. Currently we need to specify the token-account instead of the owner which is quite inconvenient.

unable to understand token Account

hello i'm trying to execute the simple vesting code , i don't understand what the comment means with DESTINATION_TOKEN_ACCOUNT ,
becuase when retrieving info from web3 it returns an object with type AccountInfo not havinga public key , please if someone could provide a full explanation !

Rust CLI Help

Following the instructions here:
https://github.com/Bonfida/token-vesting/tree/master/cli

I created the participants accounts. This step works fine

I deposited SOL into the id_owner account.

Next step says:
Deploy program and copy PROGRAM_ID.
solana deploy ../program/target/deploy/token_vesting.so --url https://devnet.solana.com --config ~/.config/solana/id_owner.json

When I run this, I get this error
Error: Unable to open program file: No such file or directory (os error 2)

How to fix?

rfc: linear vesting cli

echo "RUST_BACKTRACE=1 ./target/debug/vesting-contract-cli      \
--url https://api.devnet.solana.com                             \
--program_id $PROGRAM_ID                                        \
create                                                          \
--mint_address $MINT                                            \
--source_owner ~/.config/solana/id_owner.json                   \
--source_token_address $TOKEN_ACCOUNT_SOURCE                    \
--destination_token_address $ACCOUNT_TOKEN_DEST                 \
--release-frequency ISO8601_DURATION     
--start-date-time ISO_SORTABLE_DATE_TIME \
--end-date-time ISO_SORTABLE_DATE_TIME \
--payer ~/.config/solana/id_owner.json"                         \
--overview=true #will show overview, not really will create nothing, for linear vesting default is true, will show message overvoew=false to execute vesting
--verbose | bash              

meaning like here
image

Please how to get vesting info using getProgramAccounts

  const accountInfo = await getProgramAccounts(
    connection,
    new PublicKey("HJbNNxXVtT4beZo4W15GmNKedp7MZ8tkdPcQurFarrQE"),
    32,
    TOKEN_VESTING_PROGRAM_ID,
  );

I have the following code. I want to be able to get all vesting info for a particular wallet address

Incorrect flag name

For release schedule
when parsing the input the cli looks for release-times

Arg::with_name("release-times")
.long("release-times")

but when executing the function it looks for release-heights

let schedule_heights: Vec<u64> = values_of(arg_matches, "release-heights").unwrap();

making the program un-useable atm

which one do you guys prefer?

yarn dev rolls back all file changes

When I'm running yarn dev, the command rolls back the changed files to their original state. I'm not sure if there is some sort of linter settings or other dependencies that would be causing this.

After I run yarn dev, emacs says the file changed on disk. When I make the changes, they show up while using less, so I know the changes are making their way to the file system. I removed .git and this still continues. This is the only time I've ever ran into this.

failed to send transaction: Transaction simulation failed...

I understand what the error is attempting to say, but the issue is, there is a brand new account every time I run yarn dev

as an example

Vesting contract account pubkey: 6ddovVHQuvjyiPw2euE6Vhr9TJRHkozFxdrxLNDcP1qf contract ID: 4K8hh4chgRegqJ9i3i9iTpjuMgSixmQn47GXWJwrduoL Transaction simulation failed: Attempt to debit an account but found no record of a prior credit.

I've filled in all the fields in `src/dev.ts' with my own information, so presumably, it should not be creating a new account from nowhere. This continues to happen. Where are all of these coming from and how can I prevent this from continuing?

I'm writing it here because I don't know if this is a bug.

Preflight error [account Address already in use] [mainnet only]

I've checked it on the devnet and it was fine...
But when I am trying to use it on the mainnet I am getting this preflight error

try 1
"Create Account: account Address { address: 7L2NaXgvvPuakUaprY36TxJohAakHfmER3ZGd7NVaHPr, base: None } already in use", "Program 11111111111111111111111111111111 failed: custom program error: 0x0", "Program CChTq6PthWU82YZkbveA3WDf7s97BWhBK4Vx9bmsT743 consumed 9308 of 600000 compute units"

try 2 (same error different address)
"Create Account: account Address { address: JCwi22xyPyyDDhcEYGEdJyfUvgvwvjAHAM31uwLsmZdm, base: None } already in use", "Program 11111111111111111111111111111111 failed: custom program error: 0x0"

Accounts [7L2NaXgvvPuakUaprY36TxJohAakHfmER3ZGd7NVaHPr, JCwi22xyPyyDDhcEYGEdJyfUvgvwvjAHAM31uwLsmZdm] indeed exist and belong to program CChTq6PthWU82YZkbveA3WDf7s97BWhBK4Vx9bmsT743, they been created 2 years ago..

Because of this issue I cannot create vesting on the mainnet

Error processing Instruction 0: custom program error: 0x0

Hi,
I am trying to run the JS linear vesting program from the samples.
I am also using the deployed contract on devnet but i keep getting this error :

`Seed: 4949774028594395608608647271452266710364072223473245592442783631
Vesting contract account pubkey: HjJh7r5KgzNjePsmXuyqnCFCgoX7oCigCDZ5PvatWte1
contract ID: 4Wrnvad4AqKwUtnLu7JujW3TSEtKmwyGVTrMH9oUrjTS
Transaction simulation failed: Error processing Instruction 0: custom program error: 0x0
Program Hj9R6bEfrULLNrApMsKCEaHR9QJ2JgRtM381xgYcjFmQ invoke [1]
Program log: Entrypoint
Program log: Beginning processing
Program log: Error: Invalid instruction!
Program Hj9R6bEfrULLNrApMsKCEaHR9QJ2JgRtM381xgYcjFmQ consumed 1540 of 200000 compute units
Program Hj9R6bEfrULLNrApMsKCEaHR9QJ2JgRtM381xgYcjFmQ failed: custom program error: 0x0
/Users/x/work/y/node_modules/@solana/web3.js/lib/index.cjs.js:6591
throw new SendTransactionError('failed to send transaction: ' + res.error.message, logs);
^

SendTransactionError: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: custom program error: 0x0
at Connection.sendEncodedTransaction (/Users/x/work/y/node_modules/@solana/web3.js/lib/index.cjs.js:6591:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Connection.sendRawTransaction (/Users/x/work/y/node_modules/@solana/web3.js/lib/index.cjs.js:6550:20)
at async Connection.sendTransaction (/Users/x/work/y/node_modules/@solana/web3.js/lib/index.cjs.js:6540:12) {
logs: [
'Program Hj9R6bEfrULLNrApMsKCEaHR9QJ2JgRtM381xgYcjFmQ invoke [1]',
'Program log: Entrypoint',
'Program log: Beginning processing',
'Program log: Error: Invalid instruction!',
'Program Hj9R6bEfrULLNrApMsKCEaHR9QJ2JgRtM381xgYcjFmQ consumed 1540 of 200000 compute units',
'Program Hj9R6bEfrULLNrApMsKCEaHR9QJ2JgRtM381xgYcjFmQ failed: custom program error: 0x0'
]
}`

The owner and destination wallets are funded
I tried running through the CLI but still getting the same error.

Any help would be highly appreciated.

Error when trying to unlock and change destination + token not released after the limit lock date

Hi,

Have an error when trying to unlock or change destination + the lock date (June 21st 2021) passed but token is not released

What I did :

I did lock a SPL token, on a specific token address, it works. Date to release June 21th 2021
I change destination to another address (not a derived one), It works.

I tried to unlock before June 21st 2021, error
I tried to change destination, error.

Date is now June 22th 2021, and on the token-vesting UI, token still locked.

Regards,
Capture d’écran 2021-06-22 à 08 24 03
Capture d’écran 2021-06-22 à 08 24 25

How to retrieve contract seed for the UI

I am using the CLI to create vesting schedule, the output that I am seeing is:

RPC URL: "https://api.mainnet-beta.solana.com"
Program ID: CChTq6PthWU82YZkbveA3WDf7s97BWhBK4Vx9bmsT743
Vesting Seed: 8opHzTAnfzRpPEx21XtnrVTX28YQuCpAjcn1PczScQ4
Vesting Account Pubkey: 8bRHuxdPXHt5GiQeAFdqBhXM2Mr1qhyL1YXdHcWEsatF
Vesting Token Account Pubkey: A9DTYXGF9MNiWbcPYveEcKbDunSMNaHkc8SHtG5arZeN
Initialized: true
Mint Address: PoRTjZMPXb9T7dyU7tpLEZRQj7e6ssfAE62j2oQuc6y
Destination Token Address: 7tdfjrtxpJ3Epk1jghX7wCC3yeWnQ6Qy49JDvP5CCSQm

SCHEDULE 0
Release Height: 1
Amount: 2

SCHEDULE 1
Release Height: 28504431
Amount: 1

SCHEDULE 2
Release Height: 2850600000000000
Amount: 3

I wonder how do I go from the vesting seed of 8opHzTAnfzRpPEx21XtnrVTX28YQuCpAjcn1PczScQ4 to a number that is ready to use?

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

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

Please add back "Lock" to Bonafida UI - Rust CLI does not work

I am not sure why the "Lock" option was removed from the UI, and I (and others!) are having trouble getting the Rust CLI to work. I've followed all steps in the documentation.

First, when attempting to get the ProgramID with this command (as listed in the documentation):
solana deploy ../program/target/deploy/token_vesting.so --url https://api.mainnet-beta.solana.com --config /Users/myuser/.config/solana/id_owner.json

I get this error:

Error: Unable to open program file: No such file or directory (os error 2)

Secondly, when I attempt to lock tokens as so:

echo "RUST_BACKTRACE=1 ./target/debug/vesting-contract-cli --url https://api.mainnet-beta.solana.com --program_id XXXXX create --mint_address XXXXXX --source_owner /Users/solana/me/myusers/keyfile.json --source_token_address XXXXX --destination_address XXXXX --amounts 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,! --release-times 1640890837,1640891837,1640892837,1640893837,1640894837,1640895837,1640896837,1640897837,1640898837,1640899837,1640900837,1640901837,1640902837,1640903837,1640904837,1640905837,1640906837,1640907837,1640908837,1640909837,1640910837,1640911837,1640912837,1640913837,! --payer /Users/solana/me/myusers/keyfile.json" --verbose | bash

I get this result:

The seed of the contract is:
Please write it down as it is needed to interact with the contract.

Looks like it works, doesnt it?
When I search for the contract seed in your UI, it is nowhere to be found.

please add back the Lock option back to the UI.

A bug or sumething? Can't settle the amount.

Hi,
First of all I'm sorry if it's the wrong place to write up.
I'm new to the platform. I wanted to trade but I keep getting errors settling the amount since yesterday.
And apparently, there is not many people having the same issue because I couldn't find any on the internet posts.
I had an SS and attached it.
Screen Shot 2021-05-15 at 13 20 40

Can you help me out please,
Emre.

Create linear vesting error with cli

with cli (https://github.com/Bonfida/token-vesting/tree/master/cli)
When I run Create linear vesting I get an error.
help me T0T

[Executed Cmd]

echo "RUST_BACKTRACE=1 ./target/debug/vesting-contract-cli
--url https://api.mainnet-beta.solana.com
--program_id CChTq6PthWU82YZkbveA3WDf7s97BWhBK4Vx9bmsT743
create
--mint_address HXERJEhyoTPkcseiyjVMyAFooPACJG72dfabqDB5dZJD
--source_owner /Users/sy/Downloads/token-vesting-master/cli/id_owner.json
--source_token_address bW6zFfyhxNX9ru9t72mNJTnd8XSgRJnpWPsqrAZurEM
--destination_token_address 8Kd5iUejcfggVYRaN9LPz3gasEhXKKSBctE9A9fr7p5U
--amounts 420000000,!
--release-frequency 'P1D'
--start-date-time '2022-03-01T20:11:18Z'
--end-date-time '2022-03-03T20:11:18Z'
--payer /Users/sy/Downloads/token-vesting-master/cli/id_owner.json "
--verbose | bash

[Error Case]

  1. No response or
  2. I got the below error
    thread 'main' panicked at 'called Result::unwrap() on an Err value: ClientError { request: Some(SendTransaction), kind: RpcError(RpcResponseError { code: -32002, message: "Transaction simulation failed: Attempt to load a program that does not exist", data: SendTransactionPreflightFailure(RpcSimulateTransactionResult { err: Some(ProgramAccountNotFound), logs: Some([]), accounts: None }) }) }', src/main.rs:108: 14
    stack backtrace:
    0: rust_begin_unwind
    at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/std/src/panicking.rs:498:5
    1: core::panicking::panic_fmt
    at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/core/src/panicking.rs:107:14
    2: core::result::unwrap_failed
    at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/core/src/result.rs:1613:5
    3: core::result::Result<T,E>::unwrap
    at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/core/src/result.rs:1295:23
    4: vesting_contract_cli::command_create_svc
    at ./src/main.rs:103:9
    5: vesting_contract_cli::main
    at ./src/main.rs:611:13
    6: core::ops::function::FnOnce::call_once
    at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/core/src/ops/function.rs:227:5
    note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.

p.s How do I set the release-frequency?
(Date, hour and minute available?)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.