'Are there smart contracts in Etherium that can be called to buy other cryptocurrencies?

I want to buy Arweave coins when my contract solidety payable function is called. So I wonder are there any Smart Contracts with solidety API that provide exchange services?

I look for a function like: buy('wallet_address_to_transfer_coins_to_on_other_network', 'token_mnemonic', Amount); function that can be called within my solidety payable function and could for example sequre tokens for NFT data storedge space.

So are there cryptocurrency exchanges with solidity API?



Solution 1:[1]

if you want the tokens in other chain maybe you could try with a bridge, if not you could try with any dex in which the coin you want is listed, or maybe you could need both for the thing you want to

Solution 2:[2]

Here's a small adaption of an idea, (originally created within this external site thread, and already specifcally linked in the comments):

@Echo Off
SetLocal EnableExtensions EnableDelayedExpansion
Set "Branch=7.8.1"
Set "Vars=Major Minor Patch" & Set "p=%%"
Set "v=%Vars: =" & Set "s=!Branch:*.=!" & Call Set "!v!=!p!Branch:.!s!=!p!" & Set "Branch=!s!" & Set "v=%" & Set "!v!=!s!"
Echo Major: %Major%, Minor: %Minor%, Patch: %Patch%
Pause

Solution 3:[3]

This is another, perhaps simpler, way to do it:

@echo off
setlocal EnableDelayedExpansion

set "Branch=7.8.1"
set "MAJOR=%Branch:.=" & (if not defined MINOR (set "v=MINOR") else set "v=PATCH") & set "!v!=%"
echo MAJOR  =  %MAJOR%
echo MINOR  =  %MINOR%
echo PATCH  =  %PATCH%

EDIT 2021/12/20: New method added

I think this is the simplest way to do this:

@echo off
setlocal EnableDelayedExpansion

set "Branch=7.8.1"
set "MAJOR=%Branch:.=" & set "MINOR=!PATCH!" & set "PATCH=%"

echo MAJOR  =  %MAJOR%
echo MINOR  =  %MINOR%
echo PATCH  =  %PATCH%

Solution 4:[4]

Why is the following command line using for /F not acceptable?

set "Branch=7.8.1"
for /F "tokens=1-3 delims=." %%I in ("%Branch%") do set "MAJOR=%%I" & set "MINOR=%%J" & set "PATCH=%%K"
set "MAJOR" & set "MINOR" & set "PATCH" & rem // (just to return results)

This is most straight forward and quite easy to understand.


Anyway, a method using set consisting of two lines is this:

set "Branch=7.8.1"
set "INTER=%Branch:*.=%" & rem // (this must be on a separate line)
set "MAJOR=%BRANCH:.=" & rem/"%" & set "MINOR=%INTER:.=" & rem/"%" & set "PATCH=%INTER:*.=%"
set "MAJOR" & set "MINOR" & set "PATCH" & rem // (just to return results)

Here is a method consisting of only a single line, requiring delayed variable expansion:

set "Branch=7.8.1"
setlocal EnableDelayedExpansion
set "PATCH=" & rem // (this variable must be initially cleared)
set "MAJOR=%Branch:.=" & (if defined PATCH set "MINOR=!PATCH!") & set "PATCH=%"
set "MAJOR" & set "MINOR" & set "PATCH" & rem // (just to return results)
endlocal

The initialisation command set "PATCH=" may be combined with the subsequent line using &.


And this is a method with a single line too, not requiring delayed variable expansion, but relying on the fact that the third number (to be stored in variable PATCH) does not feature leading zeros:

set "Branch=7.8.1"
set "PATCH=" & rem // (this variable must be initially cleared)
set "MAJOR=%Branch:.=" & (if defined PATCH set /A "MINOR=PATCH") & set "PATCH=%"
set "MAJOR" & set "MINOR" & set "PATCH" & rem // (just to return results)

Again the line set "PATCH=" may be combined with the following one by &.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jhonny
Solution 2
Solution 3
Solution 4 aschipfl