That’s right!
This is a butterfly cocoon.
As soon as a caterpillar is done growing and they have reached their full size, they form themselves into a cocoon, which is also known as a chrysalis. From the outside of the cocoon, it looks as if the caterpillar may just be resting, but on the inside, the caterpillar is rapidly changing.
After the butterfly emerges from the cocoon, it will take part in the pollination of plants, which is very important for other insects and animals!