py-substrate-interface
py-substrate-interface copied to clipboard
Deprecation Error
Hi, I am starting to focus on creating an SDK to utilize the polkadot and evm functions for our substrate based chain. However, when trying to use the most recent version, I am getting a DeprecationWarning that is causing me to not make any more progress (for substrate native txs).
Importing with: from substrateinterface import SubstrateInterface
Occurs on the code: substrate = SubstrateInterface(url=base_url)
Is anyone else having this issue? I can downgrade for now, but the newest version should be working right off the bat. Please let me know if I am missing something here, thanks!
Update:
The imports of
from substrateinterface.base import SubstrateInterface
from substrateinterface.keypair import Keypair, KeypairType
worked fine. Here is an example of a transaction I did using this framework. The code examples should be updated to account for this.
Full Working Code:
# 3rd party imports
from substrateinterface.base import SubstrateInterface
from substrateinterface.keypair import Keypair, KeypairType
# connect to agung testnet
substrate = SubstrateInterface(url='wss://wss-async.agung.peaq.network', ss58_format=42)
# create keypair for user sending tx
keypair = Keypair.create_from_mnemonic(
WALLET_SEED,
ss58_format=42,
crypto_type=KeypairType.SR25519
)
# add storage
call = substrate.compose_call(
call_module='PeaqStorage',
call_function='add_item',
call_params={
'item_type': "polkadot python sdk test",
'item': "works??",
}
)
extrinsic = substrate.create_signed_extrinsic(call=call, keypair=keypair)
receipt = substrate.submit_extrinsic(extrinsic, wait_for_inclusion=True)
print(receipt)
Of course the end user will never need to see this as it will be abstracted away on our side.
Now I will be able to make great progress on the sdk. It will use python to execute our pallets (via substrate and EVM through precompiles) - whose security is ultimately settled on polkadot, this is great!
Did you by any chance install https://pypi.org/project/substrateinterface/?
The correct package is: https://pypi.org/project/substrate-interface/
Above in my first post when I executed pip show substrate-interface it displayed
Name: substrate-interface
Version: 1.7.10
installed, so yes it is correct. I already figured out the issue. In my environment I had to import with:
from substrateinterface.base import SubstrateInterface