Skip to content

Instantly share code, notes, and snippets.

@phm87
Created March 19, 2021 02:06
Show Gist options
  • Save phm87/e05912920dabbfb64f943b6a6a047d58 to your computer and use it in GitHub Desktop.
Save phm87/e05912920dabbfb64f943b6a6a047d58 to your computer and use it in GitHub Desktop.
Airdrop to erc20 hodlers

How to perform an airdrop to all hodlers of an ERC20?

Problem is that it is not possible to convert an ethereum address that never spent or signed any message to its pubkey then to the equivalent KMD/BTC address. When the ethereum adress will perform one transaction or sign a message, it will reveil its pubkey.

As discussed with sylti on CryptoFR slack, it is possible to create a webpage using web3 and metamask that will ask to sign a message without broadcasting it. The signed message is retrieved offchain and verified and used to extract pubkey.

par exemple tu fork mainnet en local au block X avec ganache-cli --fork tu extrais l'adresse eth du message signe => tu connectes web3 au fork local => token.balanceOf(adresse).call() => et tu emets le resultat sur l'adresse komodo integree dans le message

l'interet de fork mainnet a un block precis, c'est pour eviter que quelqu'un transfert les tokens =>nouvelle signature et claim plusieurs fois les tokens KMD via le service

A locak hard fork would result in a centralized solution while I prefer a decentralized solution. I was thinking about doing it in a CC included in the smartchain to airdrop, maybe adapt cc_faucet and hardcode list of ethereum addresses and balances at a point of time. Signing the message would simply proove ownership and avoid repeat-attack will be handled on CC-side. Alternative would be to use p2sh and secret = message signed would be eth addy signed.

Untested code:

let web3 = new Web3(Web3.givenProvider || "ws://localhost:8545");

// https://web3js.readthedocs.io/en/v1.2.11/web3-eth.html#signtransaction
web3.eth.signTransaction({
    from: "0xEB014f8c8B418Db6b45774c326A0E64C78914dC0",
    gasPrice: "20000000000",
    gas: "21000",
    to: '0x3535353535353535353535353535353535353535',
    value: "1000000000000000000",
    data: ""
}).then(console.log);

sign eth message

// Create a SHA3 hash of the message 'Apples'
const messageHash = web3.sha3('Apples');

// Signs the messageHash with a given account
const signature = await web3.eth.personal.sign(messageHash, web3.eth.defaultAccount);
// https://www.codementor.io/@yosriady/signing-and-verifying-ethereum-signatures-vhe8ro3h6

https://www.codementor.io/@yosriady/signing-and-verifying-ethereum-signatures-vhe8ro3h6

https://ethereum.stackexchange.com/questions/13652/how-do-you-sign-an-verify-a-message-in-javascript-proving-you-own-an-ethereum-ad

https://forum.ethereum.org/discussion/2166/signature-generation-and-verification-in-solidity

https://hukenneth.medium.com/ethereum-using-web3-js-for-message-signing-7e2935b2958c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment