-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfor_token_airdrop.js
202 lines (184 loc) · 5.42 KB
/
for_token_airdrop.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
const nearAPI = require("near-api-js"); // imports near api js
const { parseNearAmount } = require("near-api-js/lib/utils/format");
// Standard setup to connect to NEAR While using Node
const { keyStores, connect } = nearAPI;
const homedir = require("os").homedir();
const CREDENTIALS_DIR = ".near-credentials";
const credentialsPath = require("path").join(homedir, CREDENTIALS_DIR);
const keyStore = new keyStores.UnencryptedFileSystemKeyStore(credentialsPath);
let config;
// STEP 2 Choose your configuration.
// set this variable to either "testnet" or "mainnet"
// if you haven't used this before use testnet to experiment so you don't lose real tokens by deleting all your access keys
const configSetting = "mainnet";
const GAS_FOR_NFT_APPROVE = "20000000000000";
const GAS_FOR_RESOLVE_TRANSFER = "10000000000000";
const GAS_FOR_FT_TRANSFER= "4000000000000";
const MAX_GAS = "300000000000000";
const DEPOSIT = "450000000000000000000";
const ONE_YOCTO = "1";
// setting configuration based on input
switch (configSetting) {
case "mainnet":
config = {
networkId: "mainnet",
keyStore, // optional if not signing transactions
nodeUrl: "https://rpc.mainnet.near.org",
walletUrl: "https://wallet.near.org",
helperUrl: "https://helper.mainnet.near.org",
explorerUrl: "https://explorer.mainnet.near.org",
};
console.log("configuration set to mainnet ");
break;
case "testnet":
config = {
networkId: "testnet",
keyStore, // optional if not signing transactions
nodeUrl: "https://rpc.testnet.near.org",
walletUrl: "https://wallet.testnet.near.org",
helperUrl: "https://helper.testnet.near.org",
explorerUrl: "https://explorer.testnet.near.org",
};
console.log("configuration set to testnet ");
break;
default:
console.log(`please choose a configuration `);
}
const STAKING_CONTRACT_ID = "kokumokongz_staking_wallet.near";
const TOKEN_CONTRACT_ID = "kokumokongz_token_wallet.near";
const NFT_CONTRACT_ID = "banc.neartopia.near";
const AirDrop = async () => {
//Load Your Account
const near = await connect(config);
// STEP 4 enter your mainnet or testnet account name here!
const account = await near.account(TOKEN_CONTRACT_ID);
let result;
result = await account.getAccessKeys();
console.log(result);
let airdrop = [
{
name: "veejayrex.near",
amount: "200"
},
{
name: "hessmart.near",
amount: "200"
},
{
name: "newein.near",
amount: "100"
},
{
name: "a5e34454d4262f68c2a6613b76f6ecfe1f00cd3af08698e1ae4b5247d1d6e9dd",
amount: "200"
},
{
name: "moffelvdbuurt.near",
amount: "500"
},
{
name: "khanamjad096.near",
amount: "100"
},
{
name: "aldi100.near",
amount: "100"
},
{
name: "r76.near",
amount: "200"
},
{
name: "codedforum.near",
amount: "100"
},
{
name: "onium.near",
amount: "100"
},
]
for(let i=0; i<airdrop.length; i++){
const resultSend = await account.functionCall({
contractId: TOKEN_CONTRACT_ID,
methodName: "ft_transfer",
args: {
receiver_id: airdrop[i].name,
amount: parseNearAmount(airdrop[i].amount),
memo: JSON.stringify({ msg: "Airdrop to NFT Holder" })
},
gas: GAS_FOR_FT_TRANSFER,
attachedDeposit: ONE_YOCTO,
});
}
// result = await account.viewFunction(
// NFT_CONTRACT_ID,
// "nft_tokens",
// {
// from_index: "580",
// limit: 15,
// }
// );
// function isEmpty(obj) {
// for(var prop in obj) {
// if(Object.prototype.hasOwnProperty.call(obj, prop)) {
// return false;
// }
// }
// return JSON.stringify(obj) === JSON.stringify({});
// }
// for(let i=0; i<result.length; i++){
// if(isEmpty(result[i].approved_account_ids) && result[i].owner_id != "vexpremint.near" )
// {
// console.log(result[i].token_id, ":", result[i].owner_id);
// try{
// const resultSend = await account.functionCall({
// contractId: TOKEN_CONTRACT_ID,
// methodName: "ft_transfer",
// args: {
// receiver_id: result[i].owner_id,
// amount: parseNearAmount("100"),
// memo: JSON.stringify({ msg: "Airdrop to NFT Holder" })
// },
// gas: GAS_FOR_FT_TRANSFER,
// attachedDeposit: ONE_YOCTO,
// });
// } catch (error){
// console.log(error);
// }
// }
// }
// STAKING
// result = await account.functionCall({
// contractId: NFT_CONTRACT_ID,
// methodName: "nft_approve",
// args: {
// token_id: "QmVmz2KGaWW9qWvzajHSGNjpx1odxaXBaCGeaNwd8JsFyo",
// account_id: STAKING_CONTRACT_ID,
// msg: JSON.stringify({ staking_status: "Stake to Platform" })
// },
// gas: MAX_GAS,
// attachedDeposit: DEPOSIT,
// });
// CLAIMING
// result = await account.functionCall({
// contractId: STAKING_CONTRACT_ID,
// methodName: "claim_reward",
// args: {
// },
// gas: MAX_GAS,
// attachedDeposit: "1",
// });
// console.log(result);
// UNSTAKING
// result = await account.functionCall({
// contractId: STAKING_CONTRACT_ID,
// methodName: "unstake",
// args: {
// token_id: "QmVmz2KGaWW9qWvzajHSGNjpx1odxaXBaCGeaNwd8JsFyo"
// },
// gas: MAX_GAS,
// attachedDeposit: "1",
// });
// console.log(result);
};
AirDrop();