Comments (11)
Mind sharing your code or a tx id?
from token-vesting.
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.
I have the same issue. Do you guys have any solutions? Thank you.
from token-vesting.
Looks like you don't have SOL in your wallet
from token-vesting.
@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.
@dr497 I have atleast 5 SOL in the source wallet and 3 in the destination wallet.
from token-vesting.
@syedshahzebhasnain did you figure out?
from token-vesting.
@DEGA-hoangmai , no i wasnt able to figure it out. I deployed my own version and used that.
from token-vesting.
having same issue :(
from token-vesting.
@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.
@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)
- unable to understand token Account HOT 1
- Tess
- Token Vesting Ui Issue HOT 6
- Token Lock has disappeared from the UI HOT 2
- My question remains unanswered: Why was Lock option removed from the UI? HOT 4
- Please add back "Lock" to Bonafida UI - Rust CLI does not work HOT 4
- Rust CLI Help HOT 4
- rfc: linear vesting cli
- using deploy dao to ensure lock safety HOT 1
- error compiling CLI - no method named `get_latest_blockhash` found for struct `RpcClient` in the current scope HOT 2
- yarn dev rolls back all file changes
- failed to send transaction: Transaction simulation failed... HOT 6
- cargo build-bpf not work
- Transaction simulation failed: Attempt to load a program that does not exist HOT 2
- Create linear vesting error with cli
- Is there an api to undo Create linear vesting? HOT 4
- failed to send transaction: Transaction simulation failed: Error processing Instruction 0: Program failed to complete HOT 5
- Please how to get vesting info using getProgramAccounts HOT 4
- Preflight error [account Address already in use] [mainnet only] HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from token-vesting.