# Swap from Terra native to CW-20 token

**URL:** <https://classic-agora.terra.money/t/swap-from-terra-native-to-cw-20-token/5334>\
**Category:** Technical Development\
**Created:** [March 25, 2022, 6:23am UTC](https://classic-agora.terra.money/t/swap-from-terra-native-to-cw-20-token/5334 "2022-03-25T06:23:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jay](https://avatars.discourse-cdn.com/v4/letter/j/ed8c4c/32.png) [@Jay](https://classic-agora.terra.money/u/Jay)\
**Post date:** [March 25, 2022, 6:23am UTC](https://classic-agora.terra.money/t/swap-from-terra-native-to-cw-20-token/5334/1 "2022-03-25T06:23:39Z")

</div>

Hi all,

Yet another swap/smart contract interaction question, when I run the following:

USTANC\_contract = ’  
mk = _mnemonic key set elsewhere_  
spread = 0.1  
UST\_amount\_to\_be\_swapped1 = 1

def Swap\_UST\_for\_ANC(UST\_amount\_to\_be\_swapped1, mk, USTANC\_contract, spread):

```
Testwallet = terra.wallet(mk)

data = '{"swap":{"max_spread":'+str(spread)+'}}'

encodedBytes = base64.b64encode(data.encode("utf-8"))
encodedStr = str(encodedBytes, "utf-8")

send_Swap_UST_for_ANC = (
    MsgExecuteContract(
        sender=mk.acc_address,
        contract="terra14z56l0fp2lsf86zy3hty2z47ezkhnthtr9yq76", #ANC
        execute_msg={
            "send": {
                "msg": encodedStr, #'{"swap":{"max_spread":"0.005"}}' converted from json to Base64. Refer to https://docs.terraswap.io/docs/howto/swap/
                 "amount": str(UST_amount_to_be_swapped1),
                "contract": USTANC_contract 
            }
        },
    ),
)

# Send tx
tx_Swap_UST_for_ANC = Testwallet.create_and_sign_tx(
    CreateTxOptions(
    send_Swap_UST_for_ANC   
    )
)

result_tx_Swap_UST_for_ANC = terra.tx.broadcast(tx_Swap_UST_for_ANC)
print(result_tx_Swap_UST_for_ANC.txhash)

```

Swap\_UST\_for\_ANC(1000000, mk, USTANC\_contract, 0.1)

I get the following error:

LCDResponseError: Status 400 - failed to execute message; message index: 0: dispatch: Error parsing into type terraswap::pair::Cw20HookMsg: Invalid type: execute wasm contract failed: invalid request

If I change the ANC CW-20 token contract to ‘uusd’ so I can swap from UST to ANC it gives the following error:

LCDResponseError: Status 400 - Invalid contract address (decoding bech32 failed: invalid bech32 string length 4): invalid address: invalid request

I am not really sure what is going on here? Any possible fixes I can try on this one?

---

<div class="post-metadata">

**Author:** ![Jay](https://avatars.discourse-cdn.com/v4/letter/j/ed8c4c/32.png) [@Jay](https://classic-agora.terra.money/u/Jay)\
**Post date:** [March 26, 2022, 12:46pm UTC](https://classic-agora.terra.money/t/swap-from-terra-native-to-cw-20-token/5334/4 "2022-03-26T12:46:52Z")

</div>

Not yet I just get the same errors, I am trying to find the complete list of query parameters to check I am messaging the right message.

---

<div class="post-metadata">

**Author:** ![alagiz](https://sea2.discourse-cdn.com/terra/user_avatar/classic-agora.terra.money/alagiz/32/1897_2.png) [@alagiz](https://classic-agora.terra.money/u/alagiz)\
**Post date:** [March 26, 2022, 1:47pm UTC](https://classic-agora.terra.money/t/swap-from-terra-native-to-cw-20-token/5334/5 "2022-03-26T13:47:58Z")

</div>

keep in mind that @Henry is a scammer.  
[@admins](https://classic-agora.terra.money/groups/admins)?
