Giter Club home page Giter Club logo

Comments (11)

dr497 avatar dr497 commented on August 15, 2024

Mind sharing your code or a tx id?

from token-vesting.

syedshahzebhasnain avatar syedshahzebhasnain commented on August 15, 2024

Thanks for the prompt reply.
I dont see any transaction id. The code is below :

`import { Connection, PublicKey, Keypair } from '@solana/web3.js';
import fs from 'fs';
import {
Numberu64,
generateRandomSeed,
signTransactionInstructions,
} from './utils';
import { Schedule } from './state';
import { create, TOKEN_VESTING_PROGRAM_ID } from './main';

/**
*

  • Simple example of a linear unlock.
  • This is just an example, please be careful using the vesting contract and test it first with test tokens.

*/

/** Path to your wallet */
const WALLET_PATH = './keys/id_owner.json';
const DEST_WALLET_PATH = './keys/id_dest.json'

const wallet = getWallet(WALLET_PATH);
console.log( Main wallet public key: ${wallet.publicKey});
const destWallet = getWallet(DEST_WALLET_PATH)

//Keypair.fromSecretKey(
// new Uint8Array(JSON.parse(fs.readFileSync(WALLET_PATH).toString())),
//keyUint8
//);

/** There are better way to generate an array of dates but be careful as it's irreversible */
const DATES = [
new Date(2022, 12),
new Date(2023, 1),
new Date(2023, 2),
new Date(2023, 3),
new Date(2023, 4),
new Date(2023, 5),
new Date(2023, 6),
new Date(2023, 7),
new Date(2023, 8),
new Date(2023, 9),
new Date(2023, 10),
new Date(2023, 11),
new Date(2024, 12),
new Date(2024, 2),
new Date(2024, 3),
new Date(2024, 4),
new Date(2024, 5),
new Date(2024, 6),
new Date(2024, 7),
new Date(2024, 8),
new Date(2024, 9),
new Date(2024, 10),
new Date(2024, 11),
new Date(2024, 12),
];

/** Info about the desintation */
const DESTINATION_OWNER = destWallet.publicKey;
const DESTINATION_TOKEN_ACCOUNT = new PublicKey('CXduGjYbZFRm7m3jKf61LoNKopfr3kFYgGZdUunc7LLQ');

/** Token info */
const MINT = new PublicKey("EkK4MJuTffX5J6bZpU47QbXjKUqfwqoLHp9hA8x2fmUa");
const DECIMALS = 9;

/** Info about the source */
const SOURCE_TOKEN_ACCOUNT = new PublicKey('7bsVL6j59stfSsX1RNjfEYb3ogubEwPeFJ8f1NE75tRd');

/** Amount to give per schedule */
const AMOUNT_PER_SCHEDULE = 1;

/** Your RPC connection */
const connection = new Connection('https://api.devnet.solana.com');

/** Do some checks before sending the tokens */
const checks = async () => {
const tokenInfo = await connection.getParsedAccountInfo(
DESTINATION_TOKEN_ACCOUNT,
);
console.log(tokenInfo)
// @ts-ignore
const parsed = tokenInfo.value.data.parsed;
if (parsed.info.mint !== MINT.toBase58()) {
throw new Error('Invalid mint');
}
if (parsed.info.owner !== DESTINATION_OWNER.toBase58()) {
throw new Error('Invalid owner');
}
if (parsed.info.tokenAmount.decimals !== DECIMALS) {
throw new Error('Invalid decimals');
}
};

/** Function that locks the tokens /
const lock = async () => {
await checks();
const schedules: Schedule[] = [];
for (let date of DATES) {
schedules.push(
new Schedule(
/
* Has to be in seconds /
new Numberu64(date.getTime() / 1_000),
/
* Don't forget to add decimals */
new Numberu64(AMOUNT_PER_SCHEDULE * Math.pow(10, DECIMALS)),
),
);
}
const seed = generateRandomSeed();

console.log(Seed: ${seed});

const instruction = await create(
connection,
TOKEN_VESTING_PROGRAM_ID,
Buffer.from(seed),
wallet.publicKey,
wallet.publicKey,
SOURCE_TOKEN_ACCOUNT,
DESTINATION_TOKEN_ACCOUNT,
MINT,
schedules
);

const tx = await signTransactionInstructions(
connection,
[wallet],
wallet.publicKey,
instruction,
);

console.log(Transaction: ${tx});
};

lock();
function getWallet(path:string) {
return Keypair.fromSecretKey(
new Uint8Array(JSON.parse(fs.readFileSync(path).toString()))
)
}
`

from token-vesting.

DEGA-hoangmai avatar DEGA-hoangmai commented on August 15, 2024

I have the same issue. Do you guys have any solutions? Thank you.

from token-vesting.

dr497 avatar dr497 commented on August 15, 2024

Looks like you don't have SOL in your wallet

from token-vesting.

DEGA-hoangmai avatar DEGA-hoangmai commented on August 15, 2024

@dr497 Thank you for responding. I have 10 sols in the source wallet and 3 sols in the target wallet, and the payer should be source wallet.

from token-vesting.

syedshahzebhasnain avatar syedshahzebhasnain commented on August 15, 2024

@dr497 I have atleast 5 SOL in the source wallet and 3 in the destination wallet.

from token-vesting.

DEGA-hoangmai avatar DEGA-hoangmai commented on August 15, 2024

@syedshahzebhasnain did you figure out?

from token-vesting.

syedshahzebhasnain avatar syedshahzebhasnain commented on August 15, 2024

@DEGA-hoangmai , no i wasnt able to figure it out. I deployed my own version and used that.

from token-vesting.

chunghyunp avatar chunghyunp commented on August 15, 2024

having same issue :(

from token-vesting.

DEGA-hoangmai avatar DEGA-hoangmai commented on August 15, 2024

@DEGA-hoangmai , no i wasnt able to figure it out. I deployed my own version and used that.

can you share your version or any way to use js to connect to your dapp? I want to learn more. Much appreciate

from token-vesting.

syedshahzebhasnain avatar syedshahzebhasnain commented on August 15, 2024

@DEGA-hoangmai, Looks like theres an update on the https://github.com/Bonfida/token-vesting/blob/master/js/README.md with the updated contract address.
Try that out first.

Else you could always follow the steps in https://github.com/Bonfida/token-vesting/tree/master/cli to deploy your own contract and then update the TOKEN_VESTING_PROGRAM_ID on https://github.com/Bonfida/token-vesting/blob/master/js/src/main.ts to your deployed contract address.

from token-vesting.

Related Issues (20)

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.