Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kien-ngo/transfer-contract
A simplified version of thirdweb's AirdropERC721 contract used for migrating your NFTs to a new wallet. Works with thirdweb gasless options
https://github.com/kien-ngo/transfer-contract
Last synced: about 1 month ago
JSON representation
A simplified version of thirdweb's AirdropERC721 contract used for migrating your NFTs to a new wallet. Works with thirdweb gasless options
- Host: GitHub
- URL: https://github.com/kien-ngo/transfer-contract
- Owner: kien-ngo
- Created: 2023-09-04T22:43:14.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-13T17:11:51.000Z (over 1 year ago)
- Last Synced: 2024-10-18T21:34:08.066Z (3 months ago)
- Language: Solidity
- Size: 16.6 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
A simplified version of thirdweb's AirdropERC721 contract used for migrating your NFTs to a new wallet. Works with thirdweb gasless options
Usage (Node.js)
1. With gasless (very useful when you want to rescue the NFTs that are stuck in your drained wallets)
```js
try {
const _tokenAddress = process.env.TOKEN_ADDRESS!; //
const migrateContractAddress = process.env.MIGRATE_CONTRACT!; // migrate erc721
const _recipient = process.env.NEW_WALLET!; // new wallet that will receive the rescued nfts
const thirdwebSdk = ThirdwebSDK.fromPrivateKey(process.env.LEAKED_PRIVATE_KEY!, 'polygon', {
gasless: {
openzeppelin: {
relayerUrl: process.env.OZ_GASLESS_POLYGON!,
},
},
secretKey: process.env.THIRDWEB_SECRET_KEY,
});
const _tokenOwner = process.env.DRAINED_WALLET_ADDRESS!; // leakedWalletAddress
const [migrateContract, nftContract] = await Promise.all([
thirdwebSdk.getContract(migrateContractAddress),
thirdwebSdk.getContract(_tokenAddress),
]);
// You need to approve the Migrate contract to send the NFTs on your behalf
const isApproved = await nftContract.erc721.isApproved(_tokenOwner, migrateContractAddress);
if (!isApproved) await nftContract.erc721.setApprovalForAll(migrateContractAddress, true);
else console.log('contract is approved to send nfts');
const owners = await nftContract.erc721.getAllOwners();// Get all the tokenIds of the targeted collection in the drained wallet
const allTokenIds = owners.filter((item) => item.owner === _tokenOwner).map((item) => item.tokenId);
// Due to block space limit, we only send a few hundred per batch (tweak the number til it works for u)
const magicNumber = 100;
const _tokenIds = allTokenIds.length <= magicNumber ? allTokenIds : allTokenIds.slice(0, magicNumber);// Start migrating
const data = await migrateContract.call('transferERC721', [_tokenAddress, _tokenOwner, _recipient, _tokenIds]);
return res.send(data);
return res.send(_tokenIds);
} catch (err) {
console.log(err);
return res.send(err);
}
```## Foundry
**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.**
Foundry consists of:
- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools).
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network.
- **Chisel**: Fast, utilitarian, and verbose solidity REPL.## Documentation
https://book.getfoundry.sh/
## Usage
### Build
```shell
$ forge build
```### Test
```shell
$ forge test
```### Format
```shell
$ forge fmt
```### Gas Snapshots
```shell
$ forge snapshot
```### Anvil
```shell
$ anvil
```### Deploy
```shell
$ forge script script/Counter.s.sol:CounterScript --rpc-url --private-key
```### Cast
```shell
$ cast
```### Help
```shell
$ forge --help
$ anvil --help
$ cast --help
```