# NEAR Workshop | Owen | Send secure cross-chain transactions with NEAR | ETHDam 2024

- Channel: [CryptoCanal](https://streameth.org/cryptocanal)
- Date: 2024-10-07
- Duration: 21:33
- Watch: https://streameth.org/watch/yt-9ktSXNzQw9E
- YouTube: https://www.youtube.com/watch?v=9ktSXNzQw9E

## Description

#ETHDam 2024 workshop with Owen from NEAR. Learn how to construct a chain signature from a NEAR account to sign a transaction on any chain. Unlock many new possibilities, from Bitcoin ordinals marketplace to a unified multi-chain DEX.
https://twitter.com/ThePiVortex https://twitter.com/NEARProtocol https://near.org/ 

James Campbell - MC of ETHDam, Hackathon Organiser, and Web3 Developer.

ETHDam - a conference and hackathon held in the heart of Amsterdam, Netherlands from April 12th to 14th, 2024, celebrated its second edition, gathering more than 600 participants. 

In the dynamic space of ETHDam, privacy and security took center stage, featuring groundbreaking discussions on hacks, recovery, and the revolutionary work of figures like Pertsev. Privacy is dead in crypto, people that know, know. People who don’t know, should know. 
ETHDam is powered by CryptoCanal, an education and events platform growing in Amsterdam, spreading its roots to Rotterdam and Zürich.
Keep up with us to see updates on future events: https://www.cryptocanal.org/ 
Follow CryptoCanal on X: https://twitter.com/CryptoCanal
Join CryptoCanal TG Community: https://t.me/CryptoCanalCommunity 
Join CryptoCanal Discord: https://discord.com/invite/XJVjpCqQBz

We would like to thank our partners that made this event possible. 🌷
Battleship Partner 
🛳Oasis Network https://oasisprotocol.org/

Jet Ski Partner
🛩⛷  NEAR https://near.org/

Canoe Partners
🛶WAKU https://waku.org/
🛶Trail of Bits https://www.trailofbits.com/
🛶Avalanche https://www.avax.network/
🛶Privacy + Scaling Explorations https://pse.dev/en
🛶Threshold https://threshold.network/

Our Canoe Partner & Official Node Provider
🛶dRPC https://drpc.org/

Sponsor
🤝EF Ecosystem Support Program https://esp.ethereum.foundation/

Paddle Partners
🚣ChainSecurity https://chainsecurity.com/
🚣Lido https://lido.fi/
🚣Cyber Capital https://www.cyber.capital/
🚣Diva https://www.divastaking.net/
🚣Firn Protocol https://firn.cash/
🚣Beefy https://beefy.com/
🚣0xbow https://www.0xbow.io/
🚣Obscura https://obscura.build/
🚣Panther https://www.pantherprotocol.io/
🚣Maven 11 https://www.maven11.com/
🚣Zama https://www.zama.ai/
🚣zkSync https://zksync.io/
🚣Secret Network https://scrt.network/

ETHDam AfterParty Fren
🥳Bitvavo https://bitvavo.com/en

Chapters:
00:00:00 - Introduction to Secure Cross Chain Transactions
00:01:55 - Simplifying the Token Trading Process
00:03:49 - How NEAR Protocol works
00:05:37 - Enabling DeFi on Bitcoin
00:07:20 - Simplifying Transactions on Different Chains
00:09:03 - Sending a Transaction and Deriving an Address
00:10:56 - Signing and Relaying Transactions
00:12:50 - Deriving Ethereum addresses from Near accounts
00:16:28 - NEAR Accounts and Chain Signatures
00:18:06 - QR Code and Resources
00:19:53 - Control over Ethereum Addresses

## Transcript

[Music] wonderful uh I'd like to introduce Owen from near he's going to be talking about secure cross chain transactions take away s my work hello yes can you turn the lights down a little bit is that possible yes yes thank you uh yeah so as you said I'm Owen uh I'm with near I'm a oh I'm developer relations contributor and today I'm going to be talking about chain signatures chain abstraction all that good stuff uh yeah like I said I'm developer relations engineer I'm also co-founder of Vex Esports which is a cheers which is a uh well just an orts application building on near and we decided to build on near because to be honest it has the best tech and this this is me and that's my online identity so I I'm going to complain for a little bit so blockchain right now is a really fragmented experience I need to have like at least half a dozen wallets to interact with all the big chains and uh all the big applications and when I'm when I'm building an application I basically have to decide where I'm going to build my app and by doing so I I'm very limiting my total addressable market and there's also siloed liquidity so say I'm I'm very active on near but I really want to tap into the liquidity on ethereum which is just huge because n's liquidity isn't isn't too high at the moment but I just I just can't do that right um as of now and also yeah if I I I trade quite a bit on arbitrum but I get paid on near so my process is basically taking my funds from near over to uh binance and then swapping to ethereum then sending to arbitrum and then swapping from ethereum to the Token I want to buy and it's a it's a pretty labor ious process and if I wanted to make it more secure as such I could use a bridge but these Bridges the the the user experience is inconsistent and there's been a lot of hacks in the past so very fragmented not very nice experience right now but don't you worry there is a solution you just have one wallet one near account that can sign transactions on any chain whether that be uh Bitcoin salana uh evm Cosmos ecosystem you name it you can do it really as long as as long as it uh has some standards of of like public keys so even if you're setting up your own new chain or a new chain comes out you don't have to integrate this technology it's already integrated by default so what we're trying to do here is create a unified experience where you don't have to have all these wallets and you just log in to one near wallet from one place and be able to interact with all these different applications so you know what it is but how does it work so basically it works through multi-party computational programmable NPC and it uses threshold cryptography so it gets a little bit complicated here but basically you sign a transaction on near to a NPC contract saying that I want to send a transaction over to ethereum and there's like a n number of NPC nodes and and then like three fifths of them or whatever have to jointly sign this transaction without revealing or or storing the private key in one place and once you have that signed transaction it comes back to you back to your near account and then you send that over to a relayer which sends it to the Target blockchain so if I want to send it to like an ethereum uh application or I want to send ethereum or whatever and you have you you have addresses on all these accounts uh all these chains just from one one n account and that works by very very similar to like HD paths uh with like Hardware wallets so you know with like a hardware wallet Ledger you have one seed phrase but you can have multiple accounts derived from that well it basically works the same so you have one near account you Chuck in some some metadata like one two 3 4 five or Owen or whatever and that deres a different address which is tied to your near account and on each of these dresses you can store their native tokens or hold nfts or whatever like you could with a normal account so what can you actually do with it it's enabling defi on bitcoin as in you can have an account with an ordinal on and you could use this ordinal uh you you could swap it or you could use it as say uh uh as collateral on a lending protocol like like ARA and like I said before you could create a unified open web experience from a single Gateway so you just have this this this one Gateway this one website where you log into your account and you just interact with any application without having to remember a load of seed phras well have a load of seed phrases written down you just have one account sign in transact not have to care about anything you can swap Bon cons salana for link on arbitrum you can do many crazy swaps that you could just not do before without uh like bridging and having to burn tokens and and reinstate new tokens on on other chains so it's it's really it's really quite simple in the end of the day but let's go even further than this so to make it more simple we can have fast off which is basically you can log into your one near account that has access to all these other accounts with biometric so like a face scan or email and and and password and then instead of having to hold like ethereum and salana and and whatever to sign these transactions on these Target chains you just have near like the near token and this swaps it to ethereum for you and pays the gas so you don't you don't have to care about all these tokens but maybe you don't want to even hold there at all so you want to create an even more web 2 experience but have all the the the greatness of web 3 behind it you can pay for your users gas with meta transactions we've had this for years um so you you don't have to pay for any transactions on any chain basically the application itself pays for it or or a third party all right let's uh so I'm going to show like can I swap this hello is this working yes right uh so I'll I'll do a bit of a demo just like in a simple example so if you come over to like your browser just put in chain signatures see I've I've been there already and we'll see like the near docks is the first one that come up and we we have plenty of docum documentation on this so there's an example repo here which guides you through uh what what you need to basically send a transaction and derive an address so we'll just open that and it's this near multi-chain example I've already gone ahead and cloned this and just run mpm install and mpm run Dev and you will be presented with this application so I can just go in log in with my near account my password in here I'll connect one of my wallets this is on testet by the way so yeah this is the application here so you can see I'm logged in on my near wallet and I can can select what it is with this example it's just ethereum and Bitcoin so this part here is showing my address on ethereum and this bit here is the the like derivation path as such so if I want to use more addresses I can change this to uh whatever and a a new a new derivation path will create a new address and you can have like near infinite amount of these so I I'll put it back to test because I have some funds on this account and then I can put in which address I want to send it to so I'll I have another metamask wallet here and I want to send some ethereum to this account from by using my near account so I'll copy that address I'll paste it in there and so I'm requesting a signature which is calling to the NPC node to create this signature and like sign it jointly and then it's going to return it back to me and then I can decide to broadcast it this takes a little while there we go so it's been signed and it's been it's ready to be relayed so I'm going to relay it now to ethereum and it should give us a transaction there successful and it'll even give us a uh like a what you call it Explorer URL so I'll put that in and we can see that I sent .01 e to uh that that account so it should appear in my metam mask I think it was at 1.6 yeah yeah it just went up by 0.01 so you can you can expand this mod model to uh like salana uh ethereum Bitcoin what Doge whatever you want and I I'll just talk a little bit through more more of the code how this works so the the the concepts are somewhat difficult to grasp when you go deep into it like how does the MPC work uh but the code is really quite simple it's just I'm a bit of a JavaScript I can't lie but this this is just simple JavaScript so this is the file that lets you interact with ethereum so we have this this uh file it's only like a 100 lines long and we just have this ethereum class we have a a function on or or a method I guess that will derive the address so derive the ethereum address from the near account and to do this you just input the account ID so either uh the the the account I'm logged into or you could even do it so instead of typing an ethereum address I could type in another near wallet address which is a named address so I can send it to bob. n or whatever or bob. testet and I don't have to remember this ethereum account name and I just just send that over and he'll send it to their actual ethereum wallet as long as you're using the the same derivation path um and then you can have some other methods that help you along the way tell you the gas price get the balance of the account and then here we come to the create payload so when you're having the transaction it's sort of like two transactions in once so it's like a near transaction and within that transaction is the ethereum transaction uh encoded I think it's like in base 64 or whatever and that caused the NPC contract to jointly sign it they each sort of have a part of the the private key to do it um oh yeah you construct the you construct the payload before and then you request the signature which is this method here and then once you have the sign transactions you send that to the relayer which which bumps it over but you can just put this all in in like you can call them all in one so you don't have to like sign and then send the transaction that is just really for demonstration purposes you could just do it all in one call so go back to here how long do I have left sorry five minutes plus some questions so I'll I'll uh I'll talk about like a high level example here so if I want to swap say like I said Bonk for link on arbitrum well I I'll use more simple uh I want to swap Bitcoin for or ethereum I can create a contract on Nia that has these addresses and it has like one ethereum address or multiple ethereum addresses and it also has a list of Bitcoin addresses and you you set up a map and in this map it says Owen has this this Bitcoin address and I can interact with this Bitcoin address I can send funds I can retrieve funds I can uh like get an nft if I want and it's registered to me no one else can access that because I thrown away the keys to this contract and then there's also an ethereum account which is owned by someone else and to to swap these tokens what you do is you just change the Bitcoin address you put that in someone else's map so I take the Bitcoin address and I just put it in Bob's list of addresses is and he Bob gives him gives me uh his ethereum address and that's just simply swapped it but you can also do another way like uh near accounts can actually be turned into nfts themselves so you can have a near account with uh a 100 different tokens on on 10 different chains and you can turn these accounts that have access to these other accounts on other chains and send them to whoever you want uh which I I think is really quite cool and there's a there's an application called Nam Sky which automatically turns these into nfts for you uh to send so we have two bounties here the first is to do with chain signatures which I've just been going on for about 15 minutes uh so just use near chain signatures however you want to create any cool application we want to see the coolest thing we don't care if it's fully complete like it should be workable but we just want to see what crazy ideas you can come up with but like I said I'm a bit of a JavaScript hater so if you want to do something else you want to you want to create a contract in near you want to use account abstraction or or whatever um you can just integrate any part of near stack for a bounty so whether that be uh front end components stored on chain whether it be backend whether it be data availability uh and and more there's there's a lot of layers to the near teex stack so here's the QR it has a link to everything you should need uh go go ahead and scan it uh we also have like a group chat there and uh resources I think we also have a a link to we we call it a Shard dog where you can just create it set up a near account and it'll give you some some either some near tokens or some test net tokens to deploy but we've got two Devils here uh I'm inan my my cool purple hoodie so I'm quite easy to find but we have a booth downstairs just come and ask us any questions we're happy to help I'm really excited to see what people are going to build and yeah that's that's it unless we have uh some questions but I'm I'm happy to take questions outside as well thank you very much does anyone have any questions Rowan yes so I'm wondering a bit about the use case that you mentioned before so swapping ethereum with Bitcoin and you said that you in that use case you threw away the private Keys how can then the ones the one who receives the Bitcoin use them for anything so what what I mean basically is you you as a developer you set up a contract that just basically has a map of these addresses and who these addresses are tied to uh and you you might be a a good developer and you've tested this contract a lot so you know it works so you you don't want it to be because if you still had the access keys to it you could sort of control the accounts so you don't want it to be custodial so once you're confident with it you throw away the access Keys you burn them so you can't have control over these accounts but uh how you structure it is that you have a function that you uh say it h says Owen has control over this ethereum address there's a function that I say input the I input the address I want to control and what I want to do with the address I I attached the transaction like send send Bitcoin or or buy an ordinal or whatever and uh uh the the function or the method will check my account check my signature to make sure that it's actually me who is in is is wanting to do that transaction but if it's someone else who the transaction isn't associated with it will just deny and it'll be a a void transaction but when you swap the accounts then I will no longer have access to that method but the person receiving it will do that make sense amazing thank you so much Final Round of Applause thank you yeah feel free to ask me any questions afterwards cheers [Music]
